I have a TCL expect script that runs a scp command for uploading a config file to my DNS server:
#!/usr/bin/expect -f
set config "~/dnsmasq.conf"
spawn /usr/bin/scp "$config" [email protected]:/etc/dnsmasq.conf
expect {
-re ".*yes.*no.*" {
exp_send "yes\r"
exp_continue
}
-re ".*password.*" {
exp_send "$password\r"
expect {
-re ".*denied.*" {
exit 7
}
}
}
}
I would like to return a specific error code if the scp utility can not be found. Currently the script exits with a status of 1. If the script exits with a status of 7, I can handle that because I know it's an access denied error. The error that shows up in the Apache log is:
couldn't execute "/usr/bin/scp": no such file or directory
while executing
"spawn /usr/bin/scp "$config" [email protected]:/etc/dnsmasq.conf"
How can I return an error code of 5 or something at this point?