Shell output in PHP.

Discussion in 'PHP' started by TheCheesePolice, Sep 1, 2009.

  1. #1
    Good day. Basically, I've been searching around without results. I'd like to output the result of a shell command with PHP.
    Is it possible to do the above?

    E: Nevermind, someone delete ASAP please.
     
    TheCheesePolice, Sep 1, 2009 IP
  2. pneulameiro

    pneulameiro Peon

    Messages:
    440
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you can use the shell_exec function. string shell_exec ( string $cmd )

    It returns the complete output of the shell command as a string.
     
    pneulameiro, Sep 1, 2009 IP
  3. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #3
    Adding few cents:

    special quotes grave accent `, they are neither single nor double quotes,

    $output = `dir/p`; //command

    it will assign the resulting directory sorting by pagewise to varible $output.

    regards
     
    Vooler, Sep 3, 2009 IP