免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2557 | 回复: 6
打印 上一主题 下一主题

ssh in loop [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-08-25 14:26 |只看该作者 |倒序浏览
Hi All,

The script below only runs for the 1st line of file machines.list.
Could someone help explain detailedly how it runs?


#!/bin/ksh

   while read line ;
   do
       ssh myuserid@$line $1 >> $home/output.txt
   done  <machines.list



The contents of machines.list is:

proxy-01.mydomain.com
proxy-02.mydomain.com
proxy-03.mydomain.com


Thanks in advance.

论坛徽章:
0
2 [报告]
发表于 2007-08-25 14:30 |只看该作者
#!/bin/ksh -x

add -x ,run again and paste the output please .

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
3 [报告]
发表于 2007-08-25 14:42 |只看该作者
用for结构, 或者参阅:
http://bbs.chinaunix.net/thread-674903-1-1.html 第九楼

论坛徽章:
0
4 [报告]
发表于 2007-08-25 15:06 |只看该作者
FYI

$ksh -x myscript.ksh hostname
+ 0< machines.list
+ read line
+ ssh myuserid@proxy-01.mydomain.com hostname
+ 1>> $home/output.txt
+ read line

论坛徽章:
0
5 [报告]
发表于 2007-08-25 20:44 |只看该作者
原帖由 LGMENG 于 2007-8-25 15:06 发表
FYI

$ksh -x myscript.ksh hostname
+ 0< machines.list
+ read line
+ ssh myuserid@proxy-01.mydomain.com hostname
+ 1>> $home/output.txt
+ read line

first host proxy-01.mydomain.com any output ?  
btw , ssh using password authentication or public key authentication ?

论坛徽章:
0
6 [报告]
发表于 2007-08-25 22:14 |只看该作者
the result is as follows,

$cat $home/output.txt
proxy-01

and ssh uses public key authentication

论坛徽章:
0
7 [报告]
发表于 2007-08-26 13:01 |只看该作者
try change machines.list to  

localhost
proxy-01.mydomain.com
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP