Run Command Line from PHP in Ubuntu 8.04

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yuniara
    New Member
    • Aug 2008
    • 6

    Run Command Line from PHP in Ubuntu 8.04

    Hi..
    how to run command line from php in ubuntu 8.04 ?

    Thank you
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    If there's a system() or similar function in PHP like in C or Python, you can call /usr/bin/bash to create a full shell or just pass in the commands you would want to run in that shell.

    Comment

    • yuniara
      New Member
      • Aug 2008
      • 6

      #3
      Originally posted by Laharl
      If there's a system() or similar function in PHP like in C or Python, you can call /usr/bin/bash to create a full shell or just pass in the commands you would want to run in that shell.
      Thank you

      Would you like to give me some examples ...

      Thank you

      Comment

      • Laharl
        Recognized Expert Contributor
        • Sep 2007
        • 849

        #4
        Keep in mind that I know absolutely no PHP, nor do I even know if this function exists in that language...

        C(++):
        [code=c]
        //This would need main()/etc
        system("/usr/bin/bash");
        [/code]

        Python:
        [code=python]
        import os
        os.system('/usr/bin/bash')
        [/code]

        Actually...you should probably use exec() or popen() (Google for how to use them, I'm not entirely certain), as system() under *nix passes the parameters passed to it to the shell as commands to be run rather than starting a new process.

        Comment

        Working...