I have a script which is on remote server which returns exit status of the script. Now I want to execute that remote script using expect and get the exit status of the script.
My remote server script
#!/usr/bin/ksh
echo "Test script"
exit 1
My expect script on local server
#!/usr/bin/ksh
expect -c "
log_user 0
spawn ssh abc@abc /var/tmp/test.ksh
expect { password:test }
log_user 1
expect 100%
"
Output of the expect script
Test script
But I also want the exit status of my remote script i.e 1. How can i achieve this using expect.