Calling application (.exe) from PHP on XP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike Youell

    Calling application (.exe) from PHP on XP


    Hi,

    I am trying to call an application from php. I have tried exec() and
    system() and even popen() all to no avail.


    Can an application be called if it brings up a window? The app I am
    calling has a command line interface, but it insists on bringing up
    it's standard window also.


    At the moment the .exe file displays in Windows Task Manager in the
    Processes tab.

    The PHP script hangs (until timeout) and the .exe doesn't do the job it
    should.

    I am probably being daft :o)

    Thanks in advance for any help or tips,
    Mike Youell.

  • Gerry Vandermaesen

    #2
    Re: Calling application (.exe) from PHP on XP

    Maybe this passage in the exec() manual contains your answer?

    Note: If you start a program using this function and want to leave it
    running in the background, you have to make sure that the output of
    that program is redirected to a file or some other output stream or
    else PHP will hang until the execution of the program ends.


    Mike Youell wrote:[color=blue]
    > Hi,
    >
    > I am trying to call an application from php. I have tried exec() and
    > system() and even popen() all to no avail.
    >
    >
    > Can an application be called if it brings up a window? The app I am
    > calling has a command line interface, but it insists on bringing up
    > it's standard window also.
    >
    >
    > At the moment the .exe file displays in Windows Task Manager in the
    > Processes tab.
    >
    > The PHP script hangs (until timeout) and the .exe doesn't do the job it
    > should.
    >
    > I am probably being daft :o)
    >
    > Thanks in advance for any help or tips,
    > Mike Youell.[/color]

    Comment

    • Roman Ziak

      #3
      Re: Calling application (.exe) from PHP on XP

      Mike Youell wrote:[color=blue]
      > Hi,
      >
      > I am trying to call an application from php. I have tried exec() and
      > system() and even popen() all to no avail.
      >
      >
      > Can an application be called if it brings up a window? The app I am
      > calling has a command line interface, but it insists on bringing up
      > it's standard window also.
      >
      >
      > At the moment the .exe file displays in Windows Task Manager in the
      > Processes tab.
      >
      > The PHP script hangs (until timeout) and the .exe doesn't do the job it
      > should.
      >
      > I am probably being daft :o)
      >
      > Thanks in advance for any help or tips,
      > Mike Youell.
      >[/color]


      PHP executes in context of IIS (or other webserver), that means it has
      less privileges and usually cannot interact with the desktop.

      IIS has settings in Control Panel -> Administration Tools -> Services ->
      World Wide Web Publishing -> Log On tab -> Allow service to interract
      wiht desktop.

      HTH
      Roman

      Comment

      • Mike Youell

        #4
        Re: Calling application (.exe) from PHP on XP


        Hi Gerry,

        Thanks for your help.

        I piped the output to NUL and later to a file but it still didn't work.

        I think it's an XP problem, probably to do with permissions or
        something, but no log file info so it's just complete guess work.

        I tried everything suggested on news groups (going back a few years)
        and on websites, and asked a highly experienced friend yet nothing
        worked.

        So in the end I created a listener "process" (actually a 15 line DOS
        batch file for now) external to PHP which listens for system events
        triggered by PHP, i.e. PHP creates a file which the listener process
        uses to call the relevant application. The file is deleted once
        processed by the listening batch file.

        I've put some simple handshaking in there so PHP can talk to the
        listener process.

        Anyway I've sorted it. Not perfect but then what is ;o)

        Again, thanks for your help :o)

        Mike Youell.

        Comment

        • Mike Youell

          #5
          Re: Calling application (.exe) from PHP on XP


          Thanks Roman. I'm using Apache so not sure what to do about
          permissions, or whether it is to do with permissions?

          I'm also a bit nervous to reduce permissions anyway. The system I
          created (see above) I believe to be more secure as it only allows
          specific executables to be called with certain arguments only, and it
          doesn't relax any permissions, which makes it a little bit easier to
          sleep at night :o)

          Thanks,
          Mike.

          Comment

          Working...