Join the Stack Overflow Community
Stack Overflow is a community of 6.5 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

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 ?

share|improve this question
    
could you be more specific on what commands you want to use? – WhatsThePoint Dec 8 at 11:37
    
use argparse module – Pax0r Dec 8 at 11:39
    
Are any of the answers what you are trying to do? – Zafi Dec 8 at 11:52

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" )
share|improve this answer
    
Its not working. Here A is a ssh command which will log in to a remote system, then there B should execute. – Nikhil Kumar Dec 8 at 12:01
    
In that case, adjust your question. This is completely unclear and for general commands my method would work. Perhaps you have to look into libraries that allow remote login! – Zafi Dec 8 at 15:33

To get the argument :

import sys
print sys.argv
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.