-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)
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Najeeb Choudhary
  • 396
  • 1
  • 3
  • 21

1 Answers1

-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])
Arkantus
  • 120
  • 1
  • 10