Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用shell脚本在ns2中运行多个模拟_Shell_Simulation_Ns2 - Fatal编程技术网

使用shell脚本在ns2中运行多个模拟

使用shell脚本在ns2中运行多个模拟,shell,simulation,ns2,Shell,Simulation,Ns2,我正在使用ns2中的setdest实用程序使用以下脚本生成多个场景,但该脚本不起作用 #!/bin/bash dest_dir="movement" if [ -d $dest_dir ] then # Do nothing echo "'$dest_dir' is a directory" else echo "Creating directory $dest_dir"; mkdir --verbose $dest_dir fi setde

我正在使用ns2中的setdest实用程序使用以下脚本生成多个场景,但该脚本不起作用

#!/bin/bash

dest_dir="movement"

if [ -d $dest_dir ]
then
      # Do nothing
      echo "'$dest_dir' is a directory"
else
      echo "Creating directory $dest_dir";
      mkdir --verbose $dest_dir
fi

setdest_loc="/home1/ns/ns-allinone-2.34/ns-2.34/indep-utils/cmu-scen-gen/setdest/setdest";

if [ -x $setdest_loc ]
then
      # Do nothing
      echo "$setdest_loc is executable"
else
      echo "$setdest_loc does not exist or is not executable";
      exit;
fi

# Create the scenarios

for i in 0 10 20 40 100
do
      $setdest_loc -v 1 -n 25 -p $i -M 20 -t 100 -x 500 -y 500 > $dest_dir/scen-25-$i
done

echo ""
echo "Created the following files"
echo ""
ls -la $dest_dir/scen-25*
如果条件setdest不可执行,它只会回显

我们以这种方式使用setdest

setdest目录中的/setdest,那么为什么这不起作用呢?我如何在这个shell脚本中编写./setdest呢

ls -l /home1/ns/ns-allinone-2.34/ns-2.34/indep-utils/cmu-scen-gen/setdest/setdest
输出是否显示脚本是可执行的,如

 -rwxr-xr-x 1 umair Administrators 238 Aug 11 09:40 setdest
 #--^--^--^
必须至少设置一个“x”,脚本才有可能执行

如果没有,则需要更改权限

 chmod 755 /home1/ns/ns-allinone-2.34/ns-2.34/indep-utils/cmu-scen-gen/setdest/setdest
如果这不能回答您的问题,请编辑您的问题以包括上面指定的
ls-l…
命令的输出

我希望这有帮助


另外,由于您似乎是新用户,如果您得到的答案有助于您,请记住将其标记为已接受,并/或给它一个+(或-)作为有用的答案。

set-x
放在脚本顶部,以查看您的脚本实际执行的操作。如果您需要更多建议,请在此处发布结果