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 grab (if possible) the return code from "/opt/process/verify.sh" ie
- if fail, return "1" and send an email to the administrator
- if successful, return "0" and send an email to the developer.
I started reading about the trap
command. Can I use it for this purpose? Is there any other option?
source share