Nikhil Kumar Agrawal
Nikhil Kumar Agrawal

Reputation: 724

How to pass multiple arguments in os.system() in python 2.7 (Python Script).

I am creating a python script where i needed to pass 2-3 arguments in os.system(). Suppose those commands/arguments are a,b. here A should execute first then B. Is there any solution for this ?

Upvotes: 0

Views: 1181

Answers (2)

khelili miliana
khelili miliana

Reputation: 3822

To get the argument :

import sys
print sys.argv

Upvotes: 1

Zafi
Zafi

Reputation: 629

I don't really see the problem, you can just use the same commands as you would do on the command line. For instance:

import os
os.system("ls -l && echo \"hello\"")

Or if you want to execute the second command even though the first one failed:

import os
os.system("a ; b" )

Upvotes: 1

Related Questions