[root@openfire1 script]# cat test.sh 
#!/bin/bash  
#本地通过ssh执行远程服务器的脚本  
for ip in `cat iplist` 
do  
    echo $1
    if [[ -z $1 ]]; then  #"-z",如果为空 
        echo "Not find command."
        break 
    else  
        echo "$ip----------------------"
        ssh $ip $1 
    fi
done  
-------------------------------------------------------------------------
-------------------------------------------------------------------------
[root@openfire1 script]# cat test.sh 
#!/bin/bash  
  
#变量定义  
ip_array=("172.16.100.23" "172.16.100.24" "172.16.100.25" "172.16.100.26" "172.16.100.27")  
user="root"  
remote_cmd=date 
  
#本地通过ssh执行远程服务器的命令
for ip in ${ip_array[*]}  
do  
    if [ $ip = "192.168.1.1" ]; then  
        port="7777"  
    else  
        port="22"  
    fi  
    
ssh -t -p $port $user@$ip $1 
echo done! 
done  

最新文章

  1. Oracle 中 sys和system帐号的区别
  2. hdu 3966 Aragorn's Story 树链剖分 按点
  3. 【水题】NOIP201504推销员
  4. shell(1)
  5. 真正的inotify+rsync实时同步 彻底告别同步慢
  6. JAVA中LOCK
  7. Lustre文件系统测试——obdfilter-survey测试
  8. Linux基础一
  9. freemark标签中输出boolean值
  10. shell 查找与替换
  11. springMVC 多文件上传前后台demo
  12. 3G设置linux路由-iptables配置
  13. leetcode-53.最大子序和
  14. Iroha and a Grid AtCoder - 1974(思维水题)
  15. spring boot集成ehcache 2.x 用于hibernate二级缓存
  16. System.exit(int status)
  17. JSP页面与JSP页面之间传输参数出现中文乱码的解决方案
  18. 第134天:移动web开发的一些总结(二)
  19. 2018 ICPC北京 H ac自动机
  20. POJ 1041 John's trip Euler欧拉回路判定和求回路

热门文章

  1. JAVA环境变量配置后未变动配置失效处理
  2. (转) 淘淘商城系列——Redis的安装
  3. 导出数据到Excel表格
  4. ThinkPHP---框架介绍
  5. 16 this和super和构造代码块
  6. java.net.MalformedURLException: no protocol: www.baidu.com
  7. java面试题链接
  8. 透彻分析C/C++中memset函数
  9. exception对象的使用及常用方法
  10. Centos下Yum安装PHP5.5,5.6,7.0及扩展