Re: executing command with shell_exec() [message #169371 is a reply to message #169370] |
Wed, 08 September 2010 18:26 |
cerr
Messages: 33 Registered: September 2010
Karma:
|
Member |
|
|
On Sep 8, 11:23 am, cerr <ron.egg...@gmail.com> wrote:
> On Sep 8, 10:34 am, matt <matthew.leonha...@gmail.com> wrote:
>
>
>
>
>
>> On Sep 8, 12:06 pm, cerr <ron.egg...@gmail.com> wrote:
>
>>> Hi There,
>
>>> I execute a script in my php script with shell_exec():
>>> $cmd = SCRIPT_PATH."PingGPSsource.py ".$_SESSION['prgIP']." ".
>>> $_SESSION['AVLIP'];
>>> logOutput("cmd:".$cmd);
>>> $avlRet=shell_exec($cmd);
>>> logOutput("result:".$avlRet);
>
>>> Now if i execute the $cmd in a normal shell, it works with no problem
>>> but when i execute it through my php script, $avlRet stays empty. Why
>>> is that and how can I fix this?
>>> Thanks for help and suggestions!
>
>>> Ron
>
>> Does the Python script rely on any shell environment variables? Those
>> will be different between the different executions. This includes
>> $PATH, so if you're calling out to "ping", you may have to provide a
>> full path. It's hard to guess without knowing the internals of the py
>> script, but that would also be inappropriate for this group :)
>
> right! but I in fact do execute a ping after creating an ssh handle
> but i don't believe the problem is there.
> I included some debug prints into my script that get tthrough to php
> until we're at a certain position, which is weird...
> it's like this:
>
> ***script start***
> [a few global variable definitions]
> print "PingGPSsource.py - start"
> [reading command line arguments]
> print "PingGPSsource.py - Got arguments"
> print "prgIP:"+prgIP
> print "avlIP:"+avlIP
> print "prgPass:"+prgPass
> print "this is before the writelog() implementation"
> [writelog() function implementation which is fairly small]
> print "and this is after"
>
> print "start script" - this is not printing anymore and the script
> appears to be terminated!
> That's weird. isn't it?
> Any clues there? :o
> Thanbks a lot! And I'm sorry if ppl tell want to redirect me to a
> python group, i'm aware f the fact that this maybe a python issue but
> the script seems to work well when executed from the shell directly...
Okay, I just figured it out! The writelog() function which writes to a
logfile which wasn't accessible by user "apache" terminated the
script! Sorry to have used your time but thanks for the hints &
suggestions!!!
Ron
|
|
|