Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exec() question

Status
Not open for further replies.

mevasquez

Programmer
Aug 26, 2003
75
US
I have been having troubles trying to get exec to work on a Linux box. The code is as follows.

Code:
   exec('/var/[URL unfurl="true"]www/html/make-vnc.sh[/URL] $ip $port $hostname');

When I use the above code, nothing happens. When I run the command on the command line, it works. Is there a switch that I have to turn on to execute an external command?

I have tested the values of the variables and there is data.

The permissions on the folder is 777 (for testing only) apache.apache and still the file cannot be created.
TIA

Mike
 
The make-vnc.sh file permission is 755 apache.apache.

Mike
 
By any chance is safe_mode turned on in the php.ini file? If so, according to the PHP Manual, functions that execute system programs will not start programs that are not in the directory defined by safe_mode_exec_dir.
 
Hmmm...

Does it work if you explicitly call the shell?

Code:
exec('/bin/sh /var/[URL unfurl="true"]www/html/make-vnc.sh[/URL] $ip $port $hostname');
 
Did not work.

I can run the file from the command line with success but I cannot not run the file successfully from the Web page.

Mike
 
what are you expecting to happen on the browser? do you expect the vnc window to be presented to you somehow?

if so ( i doubt that this will work - i'd guess you need a java applet or something) you should at least be using echo exec() or, even better, passthru().
 
What I want the browser to do is to run
Code:
exec('/bin/sh /var/[URL unfurl="true"]www/html/make-vnc.sh[/URL] $ip $port $hostname');

The make-vnc.sh creates a file with a .vnc extension. The end results is a file name that contains the hostname.vnc. Then on the Web page I output data from the database that contains the hostname, ip and other information. I have it set up so that when I click on the ip address, the link will execute the hostname.vnc file and a vnc session pops up. I can now view the desktop of the computer. This only works with IE. I have not gotten it to work with Firefox. Firefox just opens the file with the vnc information.

I will try using passthru().

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top