0
로드 밸런서 아래의 여러 웹 서버에 bash 명령을 보내는 데 사용하는 스크립트가 있습니다. 명령을 성공적으로 보낼 수 있지만 로컬로 실행하려고합니다.읽기 명령을 실행하십시오
#!/bin/bash
echo "Type commands to be sent to web servers 1-8. Use ctrl+c to exit."
function getCommand() {
read thisCmd
echo "Sending '$thisCmd'..."
if [ ! -z "$thisCmd" ]; then
# Run command locally
echo "From web1"
cd ~
command $thisCmd
# Send to remotes
for i in {2..8}
do
echo "From web$i..."
ssh "web$i" "$thisCmd"
done
fi
echo Done
getCommand
}
getCommand
그러나 내가이 작업을 어떻게합니까
[email protected]:~$ ./sshAll.sh
Type commands to be sent to web servers 1-8. Use ctrl+c to exit.
cd html; pwd
Sending 'cd html; pwd'...
From web1
./sshAll.sh: line 11: cd: html;: No such file or directory
From web2...
/home/user/html
의 결과인가?