所以,我有两个脚本,我试图运行; mainscript.sh到远程登录并执行attached.sh,但问题是,当它执行时,我不会使用attached.sh上设置的选项,它只是回应选项列表。我认为我在使用I/O重定向时出错。我是新来的,所以任何帮助非常赞赏。Shell脚本现在在远程服务器上执行本地脚本
mainscript.sh
#!/bin/bash
echo "Please enter ther server name : "
read servername
ssh $servername "bash -s" < attached.sh
attached.sh
#!/bin/bash
OPTIONS="redhat Uptime logfile quit"
select opt in $OPTIONS; do
function redhat {
cat /etc/redhat-release
}
function Uptime {
uptime
}
function logfile {
cat /var/log/messages | less
}
function quit {
exit
}
if [ "$opt" = "redhat" ]; then
redhat
elif [ "$opt" = "Uptime" ]; then
uptime
elif [ "$opt" = "logfile" ]; then
logfile
elif [ "$opt" = "quit" ]; then
quit
else
clear
echo "bad option"
fi
done
2013-12-17
maxsis21
+0
在本地或远程服务器上是'attached.sh'? –
+0
Attached.sh在本地服务器中 –