简体   繁体   English

将raw_input的值插入os.system命令

[英]Inserting the value of raw_input into os.system command

I'm trying to get the data of my raw_input into my os.system() command. 我试图将我的raw_input的数据输入到os.system()命令中。
This is my code. 这是我的代码。

def sess_menu():
os.system('clear')
banner()
print colors["white"] + "Select Ovpn Config!!\n"
for file in os.listdir("ovpnconfs/"):
  if file.endswith(".ovpn"):
     print colors["magenta"] + (os.path.join(file))

     print colors["white"] + "\n[9] Back"
vprofile = raw_input("[-] Choose: ")
    ovpn_profile()
return

here's my function calling it, I can't seem to find a way to get the data into my command 这是我的函数调用它,我似乎找不到找到将数据放入命令的方法

def ovpn_profile():
os.system("openvpn --config ovpnconfs/*raw_input data*")

Use parameters 使用参数

def ovpn_profile(profile):
    os.system('openvpn --config ovpnconfs/"{0}"'.format(profile))

vprofile = raw_input("[-] Choose: ")
ovpn_profile(vprofile)

This might work, 这可能有效,

def ovpn_profile():
   os.system("openvpn --config ovpnconfs/{0}".format(vprofile))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM