bash - Parse configuration remote configuration file -
i want read in remote configuration file in bash script; locally following works fine:
while ifs="=" read -r name value; declare "$name=$value" done < "$cfg"
i tried same using ssh
, cat
:
ssh "$hostname" "cat $remote_cfg" | while ifs="=" read -r name value; declare "$name=$value" echo $name $value done
but variables declared in scope of while loop, how can bring them outer scope?
thanks in advance!
i have figured things out (source: http://mywiki.wooledge.org/bashfaq/024).
process substitution works:
while ifs="=" read -r name value; declare "$name=$value" done < <(ssh "$hostname" "cat ~/.cuttleline.cfg")
Comments
Post a Comment