Page 1 of 1

redirecting output inside a script run from php

Posted: Sat Feb 02, 2008 3:07 pm
by fahadist
Hi,

I am trying to execute a script in the following way

Code: Select all

exec("./run1.sh" ,$ret,$ret_val);
the run1.sh file has a simple execution of a shell command and then placing the pid of the process into a log file. the code is

Code: Select all

 
yes >> /dev/null &
echo $! >> pidList.dat
 
Problem is that with any sort of redirection, the code either gives an error code as the value for ret_val and sometimes when it does return a zero (signifying success), the script fails to reach its objective.

I have tried chmod 666 for pidList.dat and it's folder but it still didn't work

Any help will be greatly appreciated

Thanks
Fahad

Re: redirecting output inside a script run from php

Posted: Sun Feb 03, 2008 6:29 am
by iacataca
Try adding this at the beginning of the sh script:
pwd
ls

and check what $ret contains.

Re: redirecting output inside a script run from php

Posted: Sun Feb 03, 2008 11:34 am
by fahadist
the result gives
/var/www/html/webservice

and the ls also gives correct answer.

The problem, I believe is the setting of permissions for the ability to write. Any ideas?

Re: redirecting output inside a script run from php

Posted: Wed Feb 06, 2008 10:16 pm
by fahadist
The problem was with access rights I believe. I created the target file and gave it rights of 666 (read and write for all) and the script is working fine now.