shell:远程执行的方法的退出状态

shell:远程执行的方法的退出状态,shell,methods,ssh,exit,sshpass,Shell,Methods,Ssh,Exit,Sshpass,我有一个脚本,它有两种方法。一个方法在远程机器上执行命令,第二个方法相应地进行操作 run_remote(){ sshpass -p $password ssh $user@$ipaddr /bin/bash << EOF if [ -e \$file ]; then echo "file exist" exit 1 else echo "file doesnt exist" fi EOF if [ check ]; the

我有一个脚本,它有两种方法。一个方法在远程机器上执行命令,第二个方法相应地进行操作

run_remote(){
sshpass -p $password ssh $user@$ipaddr /bin/bash << EOF
   if [ -e \$file ]; then
      echo "file exist"
      exit 1
   else
      echo "file doesnt exist"
   fi
EOF
   if [ check ]; then
      echo "failed"
      exit 1
   fi
}

run_local(){
   echo "run locally"
}

#main
run_remote
if [ $? == 0 ]; then
   run_local
fi
run_remote(){

sshpass-p$password ssh$user@$ipaddr/bin/bash尝试在回显行“文件不存在”后放置出口0

感谢Rayray回答问题。EOF后添加了一个代码,该代码停止脚本发送正确的状态代码。我删除了该代码,该代码正常工作。我也更新了问题,以免造成混淆。