Already done and is working, as mentioned this script is already in use and works... i just want to add a fail safe if the script hangs due to the RPI not responding
My abstract explains how to do it, not sure which is default connection timeout for
ssh-exec, but if you want achieve explicit 30s timeout, you need to execute script async that executes
ssh-exec and that is possible with scheduler. This means that you need 2 scripts (main and script with
ssh-exec) and scheduler that have
on-event value of script name with
ssh-exec (script name, not
ssh-exec command!). Date and time for scheduler triggering must be adjusted to date (current) and time (current + add 2 sec to ensure triggering after adjustment) when main script needs to trigger it (can be disabled after main script is ended and enabled again on next main script run). Some delay (depends on added seconds to current time on scheduler time) on main script can be added after triggering scheduler to ensure that is executed and after that what I explained in prev. post (loop to check if script is running with timeout loop break).
It would be great feature for ROS to have parameter like
wait=no on
to execute script async and not use scheduler as workaround. This can be useful to some execute parallel script without need to wait end when it's not needed to be handled by caller script (for eg. manually run multiple scripts in batch to distribute load on multiple cores) or to implement some timeout logic that is not handled by commands.