我需要运行通过ssh一个多bash命令,用尽所有可能的尝试,但没有运气 -运行多bash命令不起作用
echo "3. All files found, creating remote directory on the server."
ssh -t [email protected]$host bash -c "'
if [[ -d ~/_tmp ]]; then
rm -rf ~/_tmp/*
else
mkdir ~/_tmp
fi
'" ;
echo "4. Sending files ..."
scp ${files[@]} [email protected]$host:~/_tmp/ ;
这里是输出 -
[email protected]:/tmp$ ./remotecompile
1. Please enter your id:
user
2. Please enter the names of the files that you want to compile
(Filenames *must* be space separated):
test.txt
3. All files found, creating remote directory on the server.
Password:
Unmatched '.
Unmatched '.
Connection to host.domain.com closed.
请注意,我不想把每行2-3行的bash if-then-else-fi命令放到单独的文件中。
什么是正确的做法?
顺便说一句,你需要引用更多的SCP命令:'SCP “$ {文件[@]}” “$ ID @ $主持人:〜/ _TMP /” ' - 不加引号,'$ {files [@]}'表现正好与'$ {files [*]}'相同,所有错误都与相同。 – 2014-10-30 23:46:49