|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Ssh with awk
hello, I wish to launch a command ssh by getting back certain values in a file with awk. Example of command ssh: Code:
ssh -q lpar1 mount|grep /tmp/conf-1 ssh -q lpar2 mount|grep /tmp/conf-1 Example of file: Code:
/tmp/conf-1 servers=lpar1 lpar2 lpar3 /tmp/conf-2 servers=lpar4 lpar5 lpar6 |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
If there's a question in there, I'm not sure I understand it.
|
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
This is tne content of a file: Code:
/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: Code:
ssh -q lpar1 mount|grep / tmp/conf-1 etc ... Sorry , i don't speak english very well
|
|
#4
|
|||
|
|||
|
In that case, Code:
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
|
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Thanks , it'good
But it is possible to execute the ssh command in the awk function ? |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Sure it's possible, but awk is not shell, and ill-suited to it. Code:
awk 'BEGIN { "ssh whatever" | getline }'It'd be much better to run ssh outside of awk, and pipe it in. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SSH and AWK Scripting | bradyd | Shell Programming and Scripting | 3 | 07-14-2011 06:17 PM |
| awk - skip x lines and ssh | anthonyraj75 | Shell Programming and Scripting | 1 | 03-04-2010 10:16 AM |
| setting a variable, using SSH and awk? | hcclnoodles | Shell Programming and Scripting | 5 | 10-28-2009 10:35 AM |
| Passing awk through ssh help | gbarnes | Shell Programming and Scripting | 9 | 09-23-2009 04:34 AM |
| awk using ssh variable? | RisingSun | Shell Programming and Scripting | 3 | 08-04-2008 12:07 PM |
|
|