Forking? Calling unix commands from python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sixtyfootersdude
    New Member
    • Oct 2008
    • 14

    Forking? Calling unix commands from python

    Hey all!

    Just doing some tinkering with python. I am running mac os x and I am wondering how I can call unix commands from python. In C I think I would use a fork, although it has been sometime since I have used C so I am a little fuzzy on the syntax.

    I also want to use what the unix command returns.

    Example:

    Typed in the command line: python myProgram.py

    myProgram.py needs to call the unix ls command and it needs to read in the output from the ls command.

    If someone could give me a link or tell me what term I should search for that would be super. Did some searching but wasnt really sure what to search for.

    Thanks all! Have a great night!

    JS
  • Smygis
    New Member
    • Jun 2007
    • 126

    #2
    Ether use the commands module or os.popen. And the first is a wrapper of the later.

    Comment

    • sixtyfootersdude
      New Member
      • Oct 2008
      • 14

      #3
      THanks! I will investigate!

      Comment

      Working...