Link to home
Start Free TrialLog in
Avatar of bakum
bakum

asked on

Running a Unix shell script from PHP

Hey, Experts...

I can't kick off a unix shell script from inside my PHP web page...can I?  

-thanks.
Avatar of m1tk4
m1tk4
Flag of United States of America image

You can, if your PHP is not in safe mode or restricted in a similar way by your web hosting provider. See http://us2.php.net/manual/en/ref.exec.php
Avatar of bakum
bakum

ASKER

I've upped the point value here because while those commands are useful...what I want to run is a ~script~.  And I can't seem to make the script run.  The command returns no output, return value is 1.  

It might bear upon the situation that the script makes an FTP connection and downloads any files that are in the remote directory.  Anyone think this is possible?  

Here is the PHP code I'm trying to execute...$output never returns anything:

$output = `sh myftpscript.sh >>logfile.txt`;
echo $output;

here is the myftpscript.sh...which works great when executed from the command line:

USER="UUU"
PASSWD="PPP"

ftp -n ftp.XXXXXX.com<<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
lcd releases
bin
prompt
mget  *.*
quit
END_SCRIPT

exit 0

ASKER CERTIFIED SOLUTION
Avatar of m1tk4
m1tk4
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bakum

ASKER

Outstanding.  Once again, this is truly an "EXPERTS" exchange.  

Thanks.