I have a shell script that runs on my server every day. It does some house cleaning and connects to a remote host to perform other tasks i.e.
#!/bin/bash
#do something...
...locally...
#run remote script...
ssh user@remotehost "/opt/process/verify.sh"
exit
It works fine but to be safe I would like to capture (if possible) the return code from "/opt/process/verify.sh" i.e.
- if fail, return "1" and send email to admin
- if success, return "0" and send email to developer.
I started reading about the command trap. Can I use it for that purpose? Is there another option?