1
所以,我有兩個腳本,我試圖運行; 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
在本地或遠程服務器上是'attached.sh'? – Donovan
Attached.sh在本地服務器中 – maxsis21