SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Execute a external program

    Hi everyone...

    I'm trying to execute a program (example: notepad.exe) from the browser with php...

    I've used exec(), system() or shell_exec(), they seem to work but the problem is that they never show the program a executed, the programs are running on background.

    I need the program appears on the desktop...

    Thanks..

    Apache 1.3.33
    PHP 5.0.4
    ----------

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Why do people keep trying to write Windows applications in PHP... the language was not made for this.

  3. #3
    SitePoint Zealot geekofdaweek's Avatar
    Join Date
    May 2006
    Location
    Erie, PA, USA
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First off, it would be morally wrong to post the answer to your question, as this could lead hacker wannabes to do bad things on people's computers. Secondly, The good folks who develop the PHP language know that and I doubt that they would allow their powerful and trusted web design language to have such a security flaw.
    John Stuttler
    Owner, Camboro Computers
    There are 10 kinds of people...
    Those who understand computers, and those who don't!

  4. #4
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    You do realize PHP is a SERVERside language, right?

  5. #5
    SitePoint Evangelist kuhajeya's Avatar
    Join Date
    Sep 2003
    Posts
    486
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so ,do u think php should never execute a external application. but i know these kind of scenarios are quite often in asp.net and jsp
    A CODE without a BuG is meaningless!!!

  6. #6
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    I don't think anyone implied that.

  7. #7
    SitePoint Zealot geekofdaweek's Avatar
    Join Date
    May 2006
    Location
    Erie, PA, USA
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kuhajeya
    so ,do u think php should never execute a external application. but i know these kind of scenarios are quite often in asp.net and jsp
    Well, as stymiee pointed out, PHP is a serverside language. I doubt that you could open an external application with it and get the results that you want.

    Why would you want to do this, anyway? Is it to benefit your visitors, or are you using this on an intranet for your business or something?

    ** Edit - Sorry, I was addressing Sheripchi with that last question...
    John Stuttler
    Owner, Camboro Computers
    There are 10 kinds of people...
    Those who understand computers, and those who don't!

  8. #8
    SitePoint Evangelist kuhajeya's Avatar
    Join Date
    Sep 2003
    Posts
    486
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well i think, opening pdf and excel sheets are quite often needed! how would you handle situations like those?
    A CODE without a BuG is meaningless!!!

  9. #9
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Link to a copy of the file on the server. When they click on it the file will open.

  10. #10
    Obey the Purebreed trib4lmaniac's Avatar
    Join Date
    Dec 2004
    Location
    Cornwall, UK
    Posts
    594
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does he not mean execute a program on the server?

  11. #11
    SitePoint Zealot geekofdaweek's Avatar
    Join Date
    May 2006
    Location
    Erie, PA, USA
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, there is a huge difference between a program and an application file. PDF, Excel Spreadsheets, Word Documents, etc are ALL application files. I thought the original question pertained to programs, not to data files.

    Link to a copy of the file on the server. When they click on it the file will open.
    This, of course, assumes that the client has the appropriate software installed on their computer to view the file. (If the visitor does not have Excel installed on their computer, they probably will not be able to open your Excel spreadsheet.)

    If this is just for a PDF, you can include a link to get Adobe Reader, so that the user can view your PDF file.

    You can not, however, force a persons computer to run program files, such as Anti-Virus software, on their own computer.
    John Stuttler
    Owner, Camboro Computers
    There are 10 kinds of people...
    Those who understand computers, and those who don't!

  12. #12
    SitePoint Evangelist kuhajeya's Avatar
    Join Date
    Sep 2003
    Posts
    486
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    of course may be security concern, but opening word like programs are quite commong scenarios. aren't they?

    mostly, browsers will be bring you some alert if you want to run the program on the machine , of course you cannot be complacent on this as well!
    A CODE without a BuG is meaningless!!!

  13. #13
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    There's a major difference between telling a website visitor's computer to run a program, and sending it a file which is associated with a program. The second is the common scenario.

  14. #14
    SitePoint Evangelist kuhajeya's Avatar
    Join Date
    Sep 2003
    Posts
    486
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dan,

    when you say about the second scenario, somebody else going to view that some where. this implictly means that the viewer to have to have that application running on his machine. i dont think those files are for site owner!
    A CODE without a BuG is meaningless!!!

  15. #15
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Completely true, but I don't see a non-obvious point in what you wrote?

    Let's go back to the original post. He wanted to force Notepad.exe to be run. He either meant one of two things:

    a) He's using PHP to write something closer to traditionally offline software, and wants to use it to launch the Notepad application on a Windows machine that has PHP installed. This is strange but a possibility...

    b) He wants to launch Notepad.exe on the computer of someone accessing his PHP script through a web server. This is what's simply not doable. It's not the same as sending a file, because sending a file doesn't force execution of any type of program. Sure a certain file type may be associated with Notepad on the user's computer, but the script can't force it to be and can't force it to automatically start Notepad. That's up to the user.

  16. #16
    SitePoint Evangelist kuhajeya's Avatar
    Join Date
    Sep 2003
    Posts
    486
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dan Grossman
    tt's not the same as sending a file, because sending a file doesn't force execution of any type of program. Sure a certain file type may be associated with Notepad on the user's computer, but the script can't force it to be and can't force it to automatically start Notepad. That's up to the user.
    right
    A CODE without a BuG is meaningless!!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •