By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,050 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,050 IT Pros & Developers. It's quick & easy.

please help lauching programs through php system and exec

P: 7
respected i have launch a application using the php . like nmapfe or ethreal but the basic functions like system and exec is not workiking ... the safe mode is also off .. please tell me the way to lauch these kind of console application using hyperlinks or buttons ...
other etst return system commands work like ls ... but console is not opening
Jan 25 '07 #1
Share this Question
Share on Google+
11 Replies


ronverdonk
Expert 2.5K+
P: 4,258
You are double posting! Please read the Posting Guidelines before you post in this forum!. The double thread is removed.

As to your question. Since you are running in safe mode, you must take some precautions.
If PHP is used in safe mode, system() and the other functions executing system programs refuse to start programs that are not in this directory. You have to use / as directory separator on all environments including Windows.

Note: When safe mode is enabled, you can only execute executables within the safe_mode_exec_dir. For practical reasons it is currently not allowed to have .. components in the path to the executable.

With safe mode enabled, the command string is escaped with escapeshellcmd(). Thus, echo y | echo x becomes echo y \| echo x.
Are you starting these applications of yours from the same directory as your script?

Ronald :cool:
Jan 25 '07 #2

P: 7
sorry for double posting .
and as i have said that my safe mode ooption is off not on ...as one possible confusion occurs due to that . now how can lauch the application like nmapfe
or ethreal which opens as a console . the other commands like ls and echo are working the same .
example
system("ethereal"); // this is not working
but
system("ls "): // but this is working showing the results ... text



so what is the problem .
is it not possilble to do that .. in php
thankyou .
sorry again for double posting
Jan 25 '07 #3

Motoma
Expert 2.5K+
P: 3,235
You will need to check what user your web service is running as.
Depending on the environment for that user, the programs you are trying to call may not exist in the folders specified in the $PATH for that user.
You may want to try this: use the entire path from / for the program you are trying to call:
[PHP]
system("/usr/bin/ethereal");
[/PHP]
Jan 26 '07 #4

P: 7
respected
the code you have written i have already tried it and it is not working .
code
system("/usr/bin/ethreal");
and using the system call not even the daemons can be run.
i want to start the daemon of ntop daemon but the same is not running



is there any limitation of the system call that it can not start the daemon process and fire the application (which is the console based application like ethereal or like nmapfe).



please please help whole project is blocked due to this .

or give me some alternative to how to go about this problem
thankyou...
Jan 29 '07 #5

Motoma
Expert 2.5K+
P: 3,235
respected
the code you have written i have already tried it and it is not working .
code
system("/usr/bin/ethreal");
and using the system call not even the daemons can be run.
i want to start the daemon of ntop daemon but the same is not running



is there any limitation of the system call that it can not start the daemon process and fire the application (which is the console based application like ethereal or like nmapfe).



please please help whole project is blocked due to this .

or give me some alternative to how to go about this problem
thankyou...
In order for php to start off a daemon process, the web user will need to have the permissions to do so. You will need to check your web-server configuration to determine the user that your web-server runs as, and then allow that user to perform the necessary operations. An easy way to determine if a command can be run from a php script, is to switch to that user, and run the command just as you would type it into the system() function:

Expand|Select|Wrap|Line Numbers
  1. # su - apache
  2.  
  3. $ /usr/bin/ethereal
  4.  

PLEASE NOTE: I do not know the location of the program you are trying to run, /usr/bin/ethereal was just an EXAMPLE of what you might need to do to properly run a program using the system() call.
Jan 29 '07 #6

P: 7
respected
i have tried that earlier only making my self super user and than executing the command .
please can u test command where you invoke the application in throught the web page and see the results . It will be very helpfull you could start a applicatio n like ethereal with a click on a hyperlink in the web page .
i am not getting through you about my problem so if you could give the steps it will be very helpfull
thankyou
Jan 30 '07 #7

Motoma
Expert 2.5K+
P: 3,235
respected
i have tried that earlier only making my self super user and than executing the command .
please can u test command where you invoke the application in throught the web page and see the results . It will be very helpfull you could start a applicatio n like ethereal with a click on a hyperlink in the web page .
i am not getting through you about my problem so if you could give the steps it will be very helpfull
thankyou
I am having difficulty understanding exactly what you are trying to accomplish. If you could, please explain what you want to accomplish, the difficulties you have encountered, as well as your thoughts, I am sure I will be of better help to you.
Jan 30 '07 #8

P: 7
respected
the problem i am facing here is that .
i have to make a web page using php where i have links to network tools like ntop , ethereal , nmapfe etc .
i have hyper links that point towards these links and the selected tools gets invoked .
now for the web based tools like ntop i simply give up the port number and the it gets launched .
but some of the console related tools like nmapfe and ethereal i have problem launching them .
i have used the system command and many other alternatives but the console is not getting launched .
plus i have to start the daemon also using the hyperlinks ... like daemon of ntop .. with a click ...
so main problem is how to launch a application and start a daemon ...
please i have tried everything in my knowledge .
please get me through that .

thankyou .
Feb 7 '07 #9

Motoma
Expert 2.5K+
P: 3,235
From the command line, type "whereis ethereal"
You should see a full path to the ethereal binary; this is the path you will need to type into the system function. For instance:

Expand|Select|Wrap|Line Numbers
  1. # whereis wireshark
  2. wireshark: /usr/bin/wireshark /usr/sbin/wireshark /usr/share/wireshark
  3.  
This tells me that I will need to use one of the following:
[PHP]system("/usr/bin/wireshark");
system("/usr/sbin/wireshark");
system("/usr/share/wireshark");
[/PHP]

Let it be known, wireshark and nmapfe both require root privilages to use their full functionality.
Feb 7 '07 #10

P: 7
respected
i have tried the same but for the some reason the required application is not firing up .
i have given the same system call for the ls command but that is working
but just that the application console is not firing up .

OS is linux EL 4

is there any another way that i can by using the hyperlinks in my website
i can fire the application with a click .

this is very important to me . and whole project depends upon it

thankyou
Feb 8 '07 #11

Motoma
Expert 2.5K+
P: 3,235
respected
i have tried the same but for the some reason the required application is not firing up .
i have given the same system call for the ls command but that is working
but just that the application console is not firing up .

OS is linux EL 4

is there any another way that i can by using the hyperlinks in my website
i can fire the application with a click .

this is very important to me . and whole project depends upon it

thankyou
Remember, nmapfe and ethereal both need root access to start. That means they will ask you for a password. And be running as your web user. Which means they will not display on your X11 screen regardless of what you do. And the only way to get the password in is to type it into the box that pops up.

What you may want to try is running regurlar old nmap(the command line version of nmapfe) and tethereal (the command line version of ethereal).
Feb 8 '07 #12

Post your reply

Sign in to post your reply or Sign up for a free account.