IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New more fun with ssh
#!/bin/bash
# currentMountList is what nfs file systems mounted by server
for line in $(cat servers.txt)
do
echo $line `ssh $line mount | grep nfs | awk '{print $1, $3}'`
done

what I need is output that looks like
<server1><mount1summary><mount1details>…
<server1><mount2summary><mount2details>…

what I get is <server1><mount1summary><mount1details><mount2summary><mount2details>
Know it's simple but can't see the answer

Any opinions expressed by me are mine alone, posted from my home computer, on my own time as a free American and do not reflect the opinions of any person or company that I have had professional relations with in the past 57 years. meep
New ssh is innocent here
Try replacing the entire echo line with
ssh $line "mount | grep nfs | awk '{print \"$line\", \$1, \$3}'"


Echo is the thing that eats the line breaks in the ssh response. If you absolutely need it, embed the entire sequence in double quotes, but then getting the escapes correct becomes your problem ;-)

And the second part of the problem, the missing server name, is because you get the name only once for each pass through the do loop while the ssh reponse can contain multiple lines. So you either need to process the ssh response locally, or pass the server name to the remote awk (as in the command above.)

Note: I had to escape the escape character to get the line to display correct on ziwethey. In case that somehow gets mangled, there should be one backslash before each of the double quotes inside the awk command and one before $1 and $3.

New This is the difference ...
... between a pro and a dedicated amateur. Sorry, Box. :-D
--

Drew
New He is the pro why I posted
now when you want to connect windows *nix iseries and appliances together and make them oblivious of how the data flies around, I'm the pro there.
Any opinions expressed by me are mine alone, posted from my home computer, on my own time as a free American and do not reflect the opinions of any person or company that I have had professional relations with in the past 57 years. meep
New thats got it, thanks for the explaination
Any opinions expressed by me are mine alone, posted from my home computer, on my own time as a free American and do not reflect the opinions of any person or company that I have had professional relations with in the past 57 years. meep
     more fun with ssh - (boxley) - (4)
         ssh is innocent here - (scoenye) - (3)
             This is the difference ... - (drook) - (1)
                 He is the pro why I posted - (boxley)
             thats got it, thanks for the explaination -NT - (boxley)

First came the dinosaurs, but they got all big and fat and died.
38 ms