使用 shell 脚本在 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
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*
它只是回显了 if 条件 setdest 不可执行,
我们在 setdest 目录中以这种方式使用 setdest
./setdest
,那么为什么这不起作用,我如何在此 shell 脚本中编写 ./setdest 。 ?
I am using the following script using the setdest utility in ns2 to generate multiple scenarios but the script is not working.
#!/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*
it just echoes the if condition setdest is not executable
we use setdest in this way
./setdest
in the directory of setdest ,so why this is not working how can I write ./setdest in this shell script .?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
执行
输出是否显示脚本可执行,例如
必须至少设置一个“x”才能使脚本有执行的机会。
如果没有,那么您需要更改权限
如果这不能回答您的问题,请编辑您的问题以包含上面指定的 ls -l ... 命令的输出。
我希望这有帮助。
PS,由于您似乎是新用户,如果您得到的答案对您有帮助,请记住将其标记为已接受,和/或给它 +(或 -)作为有用的答案。
Do an
Does the output show that the script is executable, like
At least one 'x' must be set for the script to have any chance of executing.
If not, then you need to change the permissions
If this does not answer your question, edit your question to include the output of the
ls -l ...
command specified above.I hope this helps.
P.S. as you appear to be a new user, if you get an answer that helps you please remember to mark it as accepted, and/or give it a + (or -) as a useful answer.