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.
bakumAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

m1tk4Commented:
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
0
bakumAuthor Commented:
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

0
m1tk4Commented:
$output will never get anything because you redirected all output to logfile txt. That is, if your sample runs anything at all - I'm not sure backticks (``) create an environment enough to find sh - try replacing it with /bin/sh myftpscript.sh.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bakumAuthor Commented:
Outstanding.  Once again, this is truly an "EXPERTS" exchange.  

Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.