I'm trying to retrieve the code return from this script:
#!/bin/bash
echo "CM 1"
ssh -i key/keyId.ppk [email protected] "
grep blabla ddd
if [ ! $? -eq 0 ]; then exit 1; fi
"
echo $?
But the last command echo $? returns 0 instead of 1.
And if try to run separately (not as a script) :
- the ssh command:
ssh -i key/keyId.ppk [email protected] - grep blabla ddd => I get the msg "grep: ddd: No such file or directory"
- then: if [ ! $? -eq 0 ]; then exit 1; fi
- then: echo $? => it returns 1 as expected
Do you have an idea why it doesn't work in my script ?
Thank you
ssh's-t?