Web Hosting Talk







View Full Version : exec or something like it


marianna
09-03-2002, 11:12 AM
hi

what I need to do is from a PHP script, spawn a GUI program (not in PHP). exec does not seem to work for that and I'm not sure how to aproach this. It's probably very simple. Could someone please help?

TIA

marianna

gaouzief
09-04-2002, 07:24 AM
http://www.php.net/manual/en/function.shell-exec.php

this should work add & at the end of the command not to get the output sent back to the script

___________________________________________________
Hassan El Forkani
Founder And Maintainer of :
http://www.WarmAfrica.com EveryOne's Africa
Freelance IT Consultant / Web Applications Developer.
Email: hassan@warmafrica.com
Tel : 0021671880014
___________________________________________________

marianna
09-04-2002, 09:54 AM
this does not work either
i think this might be a special case because the program i wish to start up is a gui
this is driving me crazy
:(

gaouzief
09-04-2002, 10:20 AM
what is the platform you are working on ? (OS, WebServer...)
also, could you post the code, so i can get a better idea.

marianna
09-04-2002, 11:34 AM
I'm on a Sun system
Solaris environment
Apache web server

right now, I'm just trying to get the test script working. something like this:


Hi!

<?

//system( "/homes/mgurtova/public_html/DL/mikehup/mikehup /usr/fdlib/bin/cvsgui
&" );
//shell_exec( "/usr/fdlib/bin/cvsgui &" );
exec( "/usr/openwin/bin/xterm -e /usr/local/gnu/bin/ls" )

?>

Done!



The "Hi" and "Done" both print, but an xterm never opens
same with shell_exec and system

the goal of my program will not be to open an xterm, of course, but this is just for testing

wakkow
09-04-2002, 05:07 PM
Your X server probably isn't allowing the script to display because its run by your web server user.. This is to prevent random people from loading programs into your X. Look at the 'xhost' command or xauth (?? not sure if thats right or not) to allow this..

You can test it by logging in as a different user and try running an graphical program.. It'll probably say something like this:

Xlib: connection to ":0.0" refused by server
Xlib: Client is not authorized to connect to Server
Error: Can't open display: :0.0

Also, I don't usually run scripts from php, but have you tried the back-tick for run a command? back-tick meaning ` (not an apostrophe, a `). For example:

echo `ls -al`;

benoire
09-04-2002, 07:11 PM
Just as a side note, I'm sure this doesn't really need saying but when executing system commands, make sure there's no holes for users to execute anything they want etc!

marianna
09-08-2002, 03:39 PM
after wakkow's post, I realized I was trying to do something very wrong and suddenly felt much shame!

the solution, if anyone is interested to know: i need to write a plugin

thank you all for your time and comments and help!