日期:2014-05-16  浏览次数:20579 次

执行远程机上的shell脚本问题
我有两台机器,分别为A,B,在B机上有个shell脚本/home/bin/test.sh,现在我想在A机上执行B机的脚本
A机IP:192.168.0.88
B机IP:192.168.0.195
脚本内容为
#!/bin/sh
touch ddd
在A机上使用命令ssh root@192.168.0.195 '/home/bin/test.sh',它让我输入密码,我输入后,但是却没执行脚本,发现并未创建文件。但在登录到B机,执行该脚本是正常的,各位大神,请指点啊……
另外我想实现非交互命令写了个expect:
#!/usr/bin/expect
set timeout 10
set host [lindex $argv 0]
set username [lindex $argv 1]
set password [lindex $argv 2]
set dpath1 [lindex $argv 3]
spawn ssh $username@host $dpath1/bin/p.sh
expect {
  "(yes/no)?"
  {
  send "yes\n"
  expect "*assword:"
  {
  send "$password\n"
  }
  }
  "*assword:"
  {
  send "$password\n"
  }
}
expect "100%"
expect eof
执行:./expect 192.168.0.195 root rootroot /home同样不行
跪求大神啊

------解决方案--------------------
改成
touch /ddd
试下,或者用echo显示点信息看行不行