-3

How can I use command line tools like ls, grep from python.

Qwertie
  • 3,602
  • 6
  • 34
  • 66
  • oh you know what, I may have misunderstood this question, and answered the command line arguments part. – pandorym Mar 16 '16 at 02:33

3 Answers3

0

This is done with subprocess

import subprocess  
subprocess.call("ls", shell=True)
Qwertie
  • 3,602
  • 6
  • 34
  • 66
0

You can use the package getopt to use command line arguments with your python code.

There is also a more advanced module called argparse that is easier to code in and provides more help and helpful error messages.

pandorym
  • 467
  • 4
  • 14
0

I think if you import os and do os.system(command) that can execute commands.

import os
os.system("your command here")
jjvandermade
  • 351
  • 4
  • 11