Bash:- expect重置rsync退出码

_EXITSUCESS_()

{

  echo -e "[$(date +"%F %T") [\e[32m\e[1mSUCESS\e[m] $@"

}

_EXITFAIL_()

{

  echo -e "[$(date +"%F %T") [\e[31m\e[1mFAIL\e[m] $@"

}

_EXITCODE_()

{

  [ $? -eq 0 ] && _EXITSUCESS_ $@ || _EXITFAIL_ $@

} 

expect -c "

set timeout -1;
# spawn -noecho bash -c \"${1}\"; spawn rsync
-avz ${USER}@${IP}:${PATH} ./; expect {   \"\(code 23\)\" {exit 0;}   \"\(code 11\)\" {exit 1;}   \"\(code 255\)\" {exit 1;}   eof {exit 0;} }"; _EXITCODE_ "退出状态"  
posted @ 2017-10-09 16:17  ithandonglin  阅读(242)  评论(0编辑  收藏  举报