redirecting output inside a script run from php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fahadist
Forum Newbie
Posts: 6
Joined: Sat Feb 02, 2008 8:40 am

redirecting output inside a script run from php

Post 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
iacataca
Forum Newbie
Posts: 5
Joined: Tue Jan 29, 2008 11:11 am

Re: redirecting output inside a script run from php

Post by iacataca »

Try adding this at the beginning of the sh script:
pwd
ls

and check what $ret contains.
fahadist
Forum Newbie
Posts: 6
Joined: Sat Feb 02, 2008 8:40 am

Re: redirecting output inside a script run from php

Post 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?
fahadist
Forum Newbie
Posts: 6
Joined: Sat Feb 02, 2008 8:40 am

Re: redirecting output inside a script run from php

Post 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.
Post Reply