I would like to get the exit code of my remote command. It's normally pretty easy, but I need to execute my command through a bastion host and I don't know take that with a easy methode.
So, this is a diagram of my architecture.
PC => Bastion => remote host
I used this code to execute my command and check the return code:
ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -At ubuntu@$ip_bastion ssh -Aq -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ubuntu@$ip_server bash <<EOF
{ ${cmd} ; } 2>&1 | sed -e 's/^/$(colors_next exec)$region:$ip:$type${normal} /'
EOF
echo $?
if [[ $? -ne 0 ]]; then
error "Error during the command execution."
exit 1
fi
But, the return code is always equal 0, while my command failed (Return 255 on the final server).
Thanks for your help :)
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)