| 您的位置:首页 > 文档 > Shell > |
文章分类热门文章 |
登陆到多台主机上去查看相关进程返回结果创建:2005-10-26 00:49:46 作者:Unlinux 来自: http://www.Unlinux.com 1.在$HOME下建立.netrc 2.chmod 0600 $HOME/.netrc 3.向.netrc中添加记录,格式如下: machine 130.34.1.5 login biansj password biansj ... 4.执行exec 130.34.1.5 "ps -ef",将在屏幕上出现远程执行结果 5.写脚本吧:) 我编写的程序如下: #!/bin/sh #filename:the test of the telnet a host. if (rlogin gd_sde >/dev/null 2>1& );then if(`ps -ef|grep account|awk '{if($8!~/grep/) print $9}'|grep account`) then echo "The account process is exist." else echo "Warnning:The account process is not exist." fi else echo "The network to gd_sde is not connected.">2& fi exit 0 但发现结果不正确。 用 ssh 连过去也可以, 比如说下面要同时在一台机器上查看多台机器的的httpd服务,如下: #!/bin/bash for hostname in 172.168.3.1 172.16.3.2 ........ do echo $hostname ssh username@$hostname "ps -ef|grep httpd " done 转载自:http://www.unlinux.com/doc/shell/20051026/257.html 【评论】 【加入收藏夹】 【大 中 小】 【打印】 【关闭】 ※ 相关链接 无相关信息 |