Find the answer to your Linux question:
Results 1 to 6 of 6
How to run shell script from PHP code with username as parameter??? and how to run exe from shell script????...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2009
    Posts
    22

    Run shell script from PHP


    How to run shell script from PHP code with username as parameter???
    and
    how to run exe from shell script????

  2. #2
    Just Joined!
    Join Date
    Sep 2011
    Posts
    52
    You can run using the passthru(); function. If you want to run it as some user you can add sudo -u username before the command.

    What do you mean by "run exe from shell"?

  3. #3
    Just Joined!
    Join Date
    Jun 2009
    Posts
    22

    Run Executable file from shell script

    i want to run executable file (i.e., maildirmake which is used to create mailboxes ---- maildirmake /var/postfix/maildirs/username. Path of maildirmake is /etc/maildrop-2.5.4/maildir/maildirmake) from shell script.
    How to do this???????

  4. #4
    Just Joined!
    Join Date
    Sep 2011
    Posts
    52
    It would be like this:
    passthru("sudo -u someusername /path/to/somecommand somevariables etc");

  5. #5
    Just Joined!
    Join Date
    Jun 2009
    Posts
    22

    Running shell script from php

    hi,

    iam running shell script from php.
    The path of shell script is /root/myscript.sh.
    1) when u give "exec(sh /root/myscript.sh)" in sample.Php
    it is not working.....???????
    2) but when u copy myscript.sh in /var/www/html
    and give like "exec(sh myscript.sh)" it is working fine as apache user & group.
    But i want different owner & group.
    SO, I prefer 1 option.
    "exec(sh /root/myscript.sh) is not working?????
    How can i do????

  6. #6
    Just Joined!
    Join Date
    Sep 2011
    Posts
    52
    I believe apache can't get to /root because of permissions.

    Try:
    chmod 755 /root

    This will however make the contents of /root accessible by anyone which is insecure

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •