eliran faigenboim
eliran faigenboim

Reputation: 3

Python call another Python script

I use my python script for pentest and I want to call another script in a new terminal. I'm getting the following error.

There was an error creating the child process for this terminal.

If I use this line with space, it only opens a new terminal with python shell but it doesn't read the path of the new script /root/Desktop/script/WPA1TKIP.py:

os.system("gnome-terminal -e python /root/Desktop/script/WPA1TKIP.py")    

Upvotes: 0

Views: 1256

Answers (3)

Robᵩ
Robᵩ

Reputation: 168876

You do not have an executable called python on your $PATH. Are you sure that python is installed, and that $PATH includes the appropriate directory?

Upvotes: 0

jadkik94
jadkik94

Reputation: 7078

That's because the command you are using is malformed, the command you are running contains a space character, so you need to quote the python [filename] part:

gnome-terminal -e "python /root/Desktop/script/WPA1TKIP.py"

Also, don't use os.system use subprocess. So you'll use similar commands in the end:

subprocess.call(['gnome-terminal', '-e', 'python /root/Desktop/script/WPA1TKIP.py'])

Note that in that case, subprocess takes care of the escaping, you just pass a list of parameters/command parts.

Upvotes: 1

mata
mata

Reputation: 69082

Try to quote the command you pass to -e:

os.system("gnome-terminal -e 'python /root/Desktop/script/WPA1TKIP.py'")

Otherwise the argument to -e is ony python, the rest is silently ignored by gnome-terminal.

Upvotes: 3

Related Questions