Skip to content Skip to sidebar Skip to footer

Passing A Variable, Set By The User, As A Parameter For A Os.system() Command

Okay so basically I am quite new at Python, however, I would like to make a simple menu system for all my basic tools I use at work my code so far is below: import os def main():

Solution 1:

You need a space, and the string concatenation operator is +, not .:

os.system("ping " + ip)

You can also use string formatting:

os.system("ping %s" % ip)

Solution 2:

You need a space between the command and the argument.

Solution 3:

Once you get it working properly, what happens if the user enters:

127.0.0.1; rm -rf /

Post a Comment for "Passing A Variable, Set By The User, As A Parameter For A Os.system() Command"