关于脚本的while循环会自动中断的问题

#!/bin/bash
if [ -z $1 ]
then
echo error
exit 1
fi
while read n
do
duankou=$(($n + 60000))
scp -o "StrictHostKeyChecking no" -P $duankou ~/Desktop/qingyunwenjian2.0 root@$1:~
ssh -o "StrictHostKeyChecking no" -p $duankou root@$1 bash ~/qingyunwenjian2.0 host${n} $n
echo success$n
done < ~/Desktop/hostlist

执行结果
[root@localhost Desktop]# bash test2.py 139.198.190.52
qingyunwenjian2.0 100% 875 0.9KB/s 00:00

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

  • base: mirrors.163.com
  • extras: mirrors.cn99.com
  • updates: mirrors.cn99.com Package net-tools-2.0-0.17.20131004git.el7.x86_64 already installed and latest version Package 2:vim-enhanced-7.4.160-1.el7_3.1.x86_64 already installed and latest version Nothing to do Connection to 139.198.190.52 closed by remote host. success2 [root@localhost Desktop]#

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问