-9

I am trying to write a Python program to to execute another Python program using subprocess. What wrong in this program, and how can I take the other Python program as an argument?

import sys
import subprocess
def dorun(args):
   subprocess.Popen([sys.executable, '%r'] % args)
dorun()

The error is:

najeeb@najeeb:~/Desktop/project$ python new-test.py nmap-test.py 
Traceback (most recent call last):
File "new-test.py", line 9, in <module>
dorun()
TypeError: dorun() takes exactly 1 argument (0 given)
7
  • 2
    dorun takes args and you aren't passing it anything. Commented Oct 1, 2015 at 10:43
  • why not run program your self.and post a write program. if you don not understand what write above please let me now. thanks Commented Oct 1, 2015 at 10:54
  • @Arkantus not work i am try already. can your post program then i am try. and thanks Commented Oct 1, 2015 at 10:57
  • @dsgdfg guy i am not try write any module. i am try write a program to execute or run other program as a argument and my above code. very simple to under stand what can i am try to do... Commented Oct 1, 2015 at 11:29
  • if any one have problem in my english please let me know Commented Oct 1, 2015 at 11:30

1 Answer 1

-1

Unless you want to be able to launch several program at one ?

import sys
import subprocess
def dorun(args):
   subprocess.Popen([sys.executable, args])
dorun(sys.argv[1])
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.