arcade16 arcade16 - 1 year ago 77
Python Question

User input in subprocess call?

I am working to automate the Wig tool in python, which will involve including a URL.

Currently I take in user input (a URL) but am having difficulty adding it to the end of the subprocess call.

import subprocess

var = raw_input("Enter a URL: ")'python3 ', var)

I know this is probably a simple question, but any help would be appreciated!

Answer Source

Pass the arguments as a list as @PadraicCunningham suggests:

args = ['python3','']

If your argument list becomes long and complicated you can bring in shlex:

import shlex
args = shlex.split('python3 {}'.format(var))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download