I am trying to do a file parse which is something like
config file:
machines= sha1 sha2 sha3 sha4
The bash script should be supporting upto 64 such machines
what I want is to place the machines in an array and then use the array to ssh to each machine.
Hi Franklin,
I tried to run by changing the config file to my config as mentioned erlier.
It prints onyl the last field (word) in the config file 3 times and does not fill anything else apart form it.
I did not understand why r u looping starting form '2'.
However, I changed it to 0 and 1 and did not get the expected result.
Like Annihilannic mentioned, I had a typo in the code, and the loop begins with the second field after the "=" so I assume this is the first machine name. Maybe it should begins with the 3th field, try it out.
awk '{for(i=2;i<=NF;i++){print $i}}' "config.file" |
while read mach; do
#do your stuff here
echo "$mach"
done
Thanks you, I got it working.
But, I want these details in a array with extra spaces removed.
However, I tried by adding a ssh command to it and does not work
When I do this the loop gets restricted to a single iteration. ?I did not see the second iteration happening. and it happens only the case of ssh.
Instead local commands works fine.
awk '{for(i=2;i<=NF;i++){print $i}}' "a" |
while read mach; do #do your stuff here
echo "hello $mach"
ssh root@rna4 uname -n # <----
echo $?
done