I want to run a script that calls remote ssh and if it gets hung, I want to be able to kill that part of the script and run another command in the script
for example I have a statement like this:
if [[ $nbserve == SENDone || $nbserve == Zray|| $nbserve == Partition ]];
then
export tapes=$(for tape in $(su - nacct -c 'ssh remote1 "cat /filer/cart/vol0/tech/File\ Lists/'"$nbserve"'/'"$move"'"'| gawk '{print $1}'|sed -n '/\([0-9]\)\(.*\)/p');
do echo $cartridge;done);
else
export cartridges=$(for cartridge in $(su - nbacct -c 'ssh remote1 "cat /filer/cart/vol0/techFile\ Lists/'"$nbserve"'/'"$movelist"'"'| tr -d " \t" |sed -n 's/\(.*)\)\([A-Z]\{1,3\}[0-9]\{1,5\}\)\(.*\)/\2/p');
do echo $cartridge;done);
fi
90% of the time this command works, but sometimes the nbserv name is not accessible this way (by ssh). In that case, I'd like to run another command that uses another syntax.
Is there a way to terminate the above statement if it hangs, and then proceed to move to the next portion of the script to run another command?
Something like a kill process command. But then how would the script go to another line? Is it possible?