我编写了一个Python脚本,用不同的种子和不同的节点数运行多个NS-3仿真。 我的脚本调用./waf --run=<scenario_name>
然后执行10个种子,更改节点数并执行10个种子,依此类推。在后台运行python脚本
问题是,我打电话给我的脚本后,我要求用户输入(运行哪个场景)。因为那raw_input
电话,我不能使用nohup myScript.py &
。我也试过CTRL + Z
,bg
和disown
。但是那也行不通。
这里是我的脚本:
#!/usr/bin/python
import subprocess
from pathlib import Path
import glob
scenario = raw_input("Type scenario (foo or bar): ")
if scenario == 'foo':
wafString = './waf --run "scratch/test-foo --nodeCount='
elif scenario == 'bar':
wafString = './waf --run "scratch/test-bar --nodeCount='
else:
print ("Wrong input!")
ns3Global = 'NS_GLOBAL_VALUE="RngRun='
numbers = [25, 50, 100] # number of nodes
for nodeCount in numbers:
for rngRun in range(1,11):
myArgument = ns3Global + str(rngRun) + '" ' + wafString + str(nodeCount) + '" '
print "*** Running experiment with " + str(nodeCount) + \
" nodes and random seed " + str(rngRun) + "\n"
subprocess.call(myArgument, shell=True)
任何帮助将非常感激。
为什么不写2个脚本?第一个脚本会询问用户输入,然后在后台启动第二个脚本(使用scenario参数)并终止。 –