I am trying to use the passthru command to run an executable.
<?php
@ $p1= $HTTP_POST_VARS["param1"];
@ $p2= $_POST["param2"];
trim($computer);
trim($sid);
if (!$p1|| !$p2)
{
echo "You have not entered the correct arguments. Please go back and try again.";
exit;
}
$command = "c:\program files\webserver\cgi-bin\myexec.exe \\\\".$computer." ".$sid;
echo $command;
passthru($command);
?>
</body>
</html>
I don't think that I have coded it wrong because I get no errors and I echo $command returns the proper value. If I substitute my command for something like "time /t" it works just fine.
I thought that safe mode might have something to do with it so I tried it with safe mode both on and off. It didn't make any difference. I have also set the safe_mode_exec_dir directive to the same path I have used in the code.
I read somewhere that it might be a permissions problem but right now the permissions to the directory and executable are set to full control for everyone.
Could someone help me pass this obstacle? I would greatly appreciate it.
By the way, I'm not to keen on turning safe mode off.
Paul
Passthru not working
Moderator: General Moderators
-
Paul Oertel
- Forum Newbie
- Posts: 18
- Joined: Fri May 31, 2002 3:44 am
- Location: Japan
-
Paul Oertel
- Forum Newbie
- Posts: 18
- Joined: Fri May 31, 2002 3:44 am
- Location: Japan
first of all: what is your problem?
EDIT:
it's from the user contributed notes for passthruThe documention does not mention that passthru() will only display standard
output and not standard error.
If you are running a script you can pipe the STDERR to STDOUT by doing
exec 2>&1
Eg. the script below will actually print something with the passthru()
function...
#!/bin/sh
exec 2>&1
ulimit -t 60
cat nosuchfile.txt
EDIT:
ahh, win32. It does not know exec 2>&1 or ulimit but <command> 2>&1 works$command = "c:\program files\....;
-
Paul Oertel
- Forum Newbie
- Posts: 18
- Joined: Fri May 31, 2002 3:44 am
- Location: Japan
Volka,
After all my explaination I forget to say what the problem was. I not getting any output returned to the web page. If I include a return value and then echo the value to the page it displays a 1.
passthru($command,$result);
echo $result;
If I'm not mistaken this means that the executable exited without out any errors.
Paul
After all my explaination I forget to say what the problem was. I not getting any output returned to the web page. If I include a return value and then echo the value to the page it displays a 1.
passthru($command,$result);
echo $result;
If I'm not mistaken this means that the executable exited without out any errors.
Paul