#!/bin/sh basepath=$(cd `dirname $0`; pwd) #获取当前文件所在路径 echo $basepath #打印当前文件所在路径 cd $basepath #切换到该路径 export LD_LIBRARY_PATH=./ #添加库路径 ./Middleware #执行程序
#mac地址设置 ifconfig eth0 down ifconfig eth0 hw ether f0:de:f1:05:d8:38 ifconfig eth0 up
1.切换用户
#!/bin/sh sudo -i expect "password:" send "123" interact
2.修改mac地址和时间
#!/bin/sh ifconfig eth0 down ifconfig eth0 hw ether f0:de:f1:05:d8:38 ifconfig eth0 up date -s 2018-07-07
3.执行脚本
#!/bin/sh ifconfig eth0 down ifconfig eth0 hw ether f0:de:f1:05:d8:38 ifconfig eth0 up cd /home/ubuntu/Desktop/qualnet20190903 basepath=`pwd` #$(cd `dirname $0`; pwd) #获取当前文件所在路径 echo $basepath #打印当前start.sh文件所在路径 cd $basepath/Turing #切换到该路径 export QUALNET_HOME=`pwd` echo $QUALNET_HOME export PATH=$PATH:$QUALNET_HOME/bin:$basepath/Turing/bin:$PATH export LD_LIBRARY_PATH=$QUALNET_HOME/gui/lib/linux64:$basepath/Lib/bin:$basepath/ExtraLib:/home/ubuntu/Program/Qt5.9.5/5.9.5/gcc_64/lib:$LD_LIBRARY_PATH cd scenarios/IEEE39-28 qualnet IEEE39-28.config
4.执行带参数脚本
#!/bin/sh ifconfig eth0 down ifconfig eth0 hw ether f0:de:f1:05:d8:38 ifconfig eth0 up cd /home/ubuntu/Desktop/qualnet20190903 basepath=`pwd` #$(cd `dirname $0`; pwd) #获取当前文件所在路径 echo $basepath #打印当前start.sh文件所在路径 cd $basepath/Turing #切换到该路径 export QUALNET_HOME=`pwd` echo $QUALNET_HOME export PATH=$PATH:$QUALNET_HOME/bin:$basepath/Turing/bin:$PATH export LD_LIBRARY_PATH=$QUALNET_HOME/gui/lib/linux64:$basepath/Lib/bin:$basepath/ExtraLib:/home/ubuntu/Program/Qt5.9.5/5.9.5/gcc_64/lib:$LD_LIBRARY_PATH cd scenarios/$1 qualnet $2