2017-09-13 8 views
-1

Ich bin ein Python-Skript zu schreiben Shell-Befehl auszuführen, und ich nehme Argumente, und ich willpassieren Variable in zu Befehl in Python

#!/usr/bin/env python 

import commands 
import subprocess 
import sys 

command = commands.getoutput('fs_cli -x "sofia profile external restart"') 

Dieser Code funktioniert, den Wert, dass an den Befehl übergeben Fein

wenn ich versuche, das Argument zu nehmen und es

nicht

Befehl = commands.getoutput auf Befehl übergeben ('fs_cli -x "sofia Profil" + sys.argv [1] + "Neustart" ')

supp Leute

Antwort

1

Sie schreiben sollte:

command = commands.getoutput('fs_cli -x "sofia profile ' + sys.argv[1] + ' restart"') 
Verwandte Themen