I wrote a simple script that calls a function in a while loop. I decided the while loop was working correctly. In the do section, I call the function. This also works great. However, as soon as I execute the command on the remote host using ssh in the function implementation, this seems to break the while loop. For the first iteration, the function call succeeds, the command is called on the remote host, and the result is returned as expected. However, then the script ends as if I had executed the output in the implementation of the function, which I havent't.
#!/bin/bash function update_relevant_domUs() { if [ $# -eq 0 ] then fatal not enough arguments fi if [ $# -gt 2 ] then fatal "unsupported number of arguments $#" fi if [ $# -eq 2 ] && [ "$1" != "Domain-0" ] && [ "$1" != "Name" ] then
If I replace the string
local res=`$cmd`
with
local res=`echo $cmd`
The outer while loop executes as expected. Any help on this would be greatly appreciated.
Best wishes,
ajag
source share