+ -
当前位置:首页 → 问答吧 → ssh 调用自定义函数?

ssh 调用自定义函数?

时间:2011-01-27

来源:互联网

大概内容如下自定义了一个fun 函数,想把这个函数在所有节点里面执行一下 节点间已经建立ssh信任,测试了一下只能执行命令,
好像调用不了脚本里面的函数,有什么办法可以解决?
1.sh  

fun()
{
  echo "nihoa"
  cd /tmp
  touch `hostname`

}

for i in node1 node2 node3 node4 ...
do
   ssh root@$i  fun
done

作者: wangdonsy   发布时间: 2011-01-27

Add your function into the login startup scripts such as /etc/profile or /home/root/.profile ... on all of the nodes.

作者: nhw_cs   发布时间: 2011-01-27

把fun函数添加到环境中

作者: justlooks   发布时间: 2011-01-27