hello,
I wish to launch a command ssh by getting back certain values in a file with awk.
Example of command ssh:
ssh -q lpar1 mount|grep /tmp/conf-1
ssh -q lpar2 mount|grep /tmp/conf-1
Example of file:
/tmp/conf-1 servers=lpar1 lpar2 lpar3 /tmp/conf-2 servers=lpar4 lpar5 lpar6
Scott
2
If there's a question in there, I'm not sure I understand it.
This is tne content of a file:
/tmp/conf-1 servers=lpar1 lpar2 lpar3
/tmp/conf-2 servers=lpar4 lpar5 lpar6
By leaving of the file, I would like to get back data with awk and launched an unix command in the awk like this:
ssh -q lpar1 mount|grep / tmp/conf-1 etc ...
Sorry , i don't speak english very well
PikK45
4
In that case,
var="/tmp/conf-1 servers=lpar1 lpar2 lpar3"
echo $var | sed 's/=/ /g' | awk '{for(i=3;i<=NF;i++){print "ssh -q "$i" mount|grep "$1}}'
This should work
Thanks , it'good
But it is possible to execute the ssh command in the awk function ?
Sure it's possible, but awk is not shell, and ill-suited to it.
awk 'BEGIN { "ssh whatever" | getline }'
It'd be much better to run ssh outside of awk, and pipe it in.