Write intermediate values to Status Columns
You can use the "connectd_task_notify" script, or functions in the sample scripts to display information in the Status Columns to help you debug your scripts. If you really need to make sure you see the value, add a "sleep" command to your script after writing to the Status Column. The sleep command will pause the execution of the script for the given number of seconds.
#
# Status column A
#
Status_A()
{
ret=$(usr/bin/connectd_notify a $jobid $api_server "$1")
}
...
Status_A "Variable: $variable"
Logging
- Use the "Log()" function shown in several of the examples. This writes selected information into a log file in the $DEBUG_DIR folder. This information will not be stored if the device is rebooted.
#
DEBUG_DIR=/tmp
# log to /tmp if DEBUG_ON is set
DEBUG_ON=1
#
Log()
{
if [ $DEBUG_ON -gt 0 ]; then
ts=$(date)
echo "$ts $1" >> ${DEBUG_DIR}/$(basename $0).log
fi
}
....
# end of script
Job_Complete
- Use the "logger" command to write values to the syslog. This information will generally be stored in the syslog and its backup files if the device is rebooted.
Use "rerun.sh" to execute a Bulk Script in shell debug mode
If your script terminates unexpectedly, it can be very difficult to debug. You should comment out all calls to "Job_Complete" or "Job_Failed" temporarily. Both "Job_Complete" and "Job_Failed" reset the Task Server for the given Task ID. You want to make sure that the Task Server stays open until you're done debugging.
Download rerun.sh and copy it to your device at /usr/bin.
chmod +x /usr/bin/rerun.sh
sudo rerun.sh
...
++ basename /tmp/Cloak-SSH.sh
+ getopts l: OPT
+ Status_A ''
++ /usr/bin/connectd_task_notify a A34B8B5D-49F6-4DC9-6B4B-F33CB6E75FE6 api.remot3.it/apv/v27/ ''
/usr/bin/connectd_task_notify: 162: /usr/bin/connectd_task_notify: s: not found
+ ret='403 FAIL'
+ Status_B ''
++ /usr/bin/connectd_task_notify b A34B8B5D-49F6-4DC9-6B4B-F33CB6E75FE6 api.remot3.it/apv/v27/ ''
....