I’m trying to run a command as a different user and save the return code for further processing.
Is this possible in bash?
ret=99
pid=1234
su - deploy -c "cd $PROJECT_ROOT; kill -9 `echo $pid`; ret=$?" >> mylog.log 2>&1
echo $ret # <= $ret still equals 99 when I want it to equal 0 or 1
Not like that.