我想在服务器A上将脚本test.sh的内容上传到服务器B上,以下是我的代码
test.sh //要上传的脚本
#!/bin/bash
function log_echo()
{
mkdir 2290
chmod 777 2290
cd 2290
touch ttt
chmod 777 ttt
}
function log_cat()
{
code=$(cat<&0)
echo $code
ret=$?
echo $ret
}
cmd=$1
shift
$cmd "$@"
remote.sh //执行上传动作的脚本
#!/bin/bash
cmd=$(cat<&0)
cmd1=$(cat<<REMOTE
$cmd
REMOTE)
ssh agishl@1.1.1.1<<EOF_END
echo "$cmd1">>test.sh
./test.sh log_echo
EOF_END
echo 1
两台机器间已配置了信任关系,执行remote.sh脚本后会报错
Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.
/bin/bash: Event not found.
如果我把test.sh脚本中#!/bin/bash改成#\!/bin/bash,又会报
Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.
Unmatched ".
求大神帮忙