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

发布于 2024-11-29 11:09:20 字数 921 浏览 0 评论 0原文

我正在使用以下脚本,并使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光清浅 2024-12-06 11:09:20

执行

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 ... 命令的输出。

我希望这有帮助。

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

Do an

ls -l /home1/ns/ns-allinone-2.34/ns-2.34/indep-utils/cmu-scen-gen/setdest/setdest

Does the output show that the script is executable, like

 -rwxr-xr-x 1 umair Administrators 238 Aug 11 09:40 setdest
 #--^--^--^

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

 chmod 755 /home1/ns/ns-allinone-2.34/ns-2.34/indep-utils/cmu-scen-gen/setdest/setdest

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文