please help lauching programs through php system and exec

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • intheend
    New Member
    • Jan 2007
    • 7

    please help lauching programs through php system and exec

    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
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    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.
    Originally posted by PHP doc
    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:

    Comment

    • intheend
      New Member
      • Jan 2007
      • 7

      #3
      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("etherea l"); // 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

      Comment

      • Motoma
        Recognized Expert Specialist
        • Jan 2007
        • 3236

        #4
        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]

        Comment

        • intheend
          New Member
          • Jan 2007
          • 7

          #5
          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...

          Comment

          • Motoma
            Recognized Expert Specialist
            • Jan 2007
            • 3236

            #6
            Originally posted by intheend
            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:

            Code:
            # su - apache
            
            $ /usr/bin/ethereal

            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.

            Comment

            • intheend
              New Member
              • Jan 2007
              • 7

              #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

              Comment

              • Motoma
                Recognized Expert Specialist
                • Jan 2007
                • 3236

                #8
                Originally posted by intheend
                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.

                Comment

                • intheend
                  New Member
                  • Jan 2007
                  • 7

                  #9
                  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 .

                  Comment

                  • Motoma
                    Recognized Expert Specialist
                    • Jan 2007
                    • 3236

                    #10
                    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:

                    Code:
                    # whereis wireshark
                    wireshark: /usr/bin/wireshark /usr/sbin/wireshark /usr/share/wireshark
                    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.

                    Comment

                    • intheend
                      New Member
                      • Jan 2007
                      • 7

                      #11
                      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

                      Comment

                      • Motoma
                        Recognized Expert Specialist
                        • Jan 2007
                        • 3236

                        #12
                        Originally posted by intheend
                        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).

                        Comment

                        Working...