• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

PHP exec() grabbing stdout+stderr

mcplaayer

n00b
Joined
Dec 29, 2004
Messages
59
NOT dead anymore!

So, I figured out how to grab both stdout and std err by doing 2>&1, and that exposed the real problem.

There is an application that is called through the exec() call and it turns out that I cannot execute it through PHP.

The error message I get is "esql: cannot execute". However I can do this call successfully through my command line. PHP isn't running from safe mode, and I can't figure out why the hell i can't make this call through exec().

Any ideas?

HTML:
        $command = "./esql get-udl.sql 2>&1";
	print "<pre>The exec command: $command</pre> <br>";

        exec($command, $output);

The output is:
HTML:
sh: ./esql: cannot execute
 
Does php have permision to execute the file? (chmod 777 to test?)
 
Well that's the thing...since this is a tool that is installed on our cluster server I don't know how to check if PHP has permissions to run this app.

However, I tried creating a wrapper shell script (get-All) to call this app, with chmod 777 and it said that the app (esql) could not be found


PHP:
exec("./get-All ALLOCATOR release 2>&1" , $output)

contents of get-All:
Code:
esql << EOF
select version from $2
where prod_id = (select id from product where product = '$1')
EOF

output:

PHP:
./get-All: esql: not found

I'm not very UNIX saavy but how do I check permissions on applications installed?
 
I didnt know PHP had that low level power, nice. I wrote a lot of linux shell scripts dealing with forks and exec commands, anywho ....


You can check file permissions by going to your folder and typing "ls -la" the -la parameter shows your RWX permissions for groups, users, and other misc things. If you want to make it readable, executable, and editable by all you can type the command "chmod 777 yourfile.ext". You will want to look up some of the chmod program attributes to see what fits your needs best as 777 is totally open for anyone to use and there are no restrictions. chmod changes permissions for files/folders in *nix.
 
Yup i got chmod down,

Found the error though, I wasn't specifying the full actual path for the app.

so I found out what that was through the "type esql" command.

That was one command i didn't have down :p
 
Back
Top