关于ssh -n
来源:互联网 发布:工业软件有哪些 编辑:程序博客网 时间:2024/06/05 19:23
关于ssh -n,man 提示为:redirects stdin from /dev/null. This must be used when ssh is run in the background.
有人知道大概是什么意思吗?
因为我有这样一个问题:复制代码复制代码
有人知道大概是什么意思吗?
因为我有这样一个问题:
- while read input
- do
- file=$(echo $input |awk '{print $1}')
- md5=$(echo $input | awk '{print $2}')
- scp /data/$file root@10.1.1.2:/data
- md5_curr=`ssh root@10.1.1.2 "md5sum /data/$file" | awk '{print $1}'`
- if [ $md5 != $md5_curr ];then
- echo "MD5 Error"
- fi
- done < /data/a.txt
- # cat /data/a.txt
- 1.txt asdfasdfasdfadsf
- 2.txt dafsadsfasfdagff
这个脚本只能够scp 1.txt,但read 第二行时显示为空。
必须在ssh,上加上-n才可以read第二行。是不是stdin变了,不再是/data/a.txt??
------------------
因为连接没有断开
而-n会运行完毕后,自动断开连接
---------------------
ssh时,ssh从while里继承stdin为/data/a.txt,然后把值读取了,但这些值对它来说没意义,所以被忽略了,然后继续执行md5sum的命令。这时while再从/data/a.txt读时,已经为空。
-n 后设定ssh的stdin为/dev/null,这样就不会继承while的stdin???
-------------------
这就是原因,这个while重定向会先exec n<&0把标准输入copy一份存起来,然后exec 1<$servers_filename,然后开始循环,但你循环内部没有指定-n,ssh命令默认读标准输入就是把文件读了。
但我完全没发现ssh会读标准输入啊,不知道了。
- 关于ssh -n
- 关于SSH
- 关于ssh
- 关于SSH
- 关于SSH
- 关于\r,\n,\r\n
- 关于\n,\r,\r\n
- 关于SSH的优点
- 关于ssh超时退出
- 关于SSH的说明
- java关于SSH解释
- 关于ssh编码问题
- 关于ssh的安全
- 关于SSH整合JSON
- 关于ssh 使用批注
- 关于SSH暴力破解
- 关于SSH的总结
- 关于ssh的争议
- Windows 8 metro 学习笔记
- HTMLParser
- 实现RTP协议的H.264视频传输系统
- uva 755 - 487--3279
- 实现RTP协议的H.264视频传输系统
- 关于ssh -n
- httpclient 超时设置
- 我理解的AS3的内存泄露与垃圾回收
- mfc笔记-画图工具
- JS事件监听器
- Python实用技巧-成为Pythoner必经之路
- 网络1——概述和物理层
- H264码流打包分析
- javascript 闭包理解