Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

df -h script to 10 servers and append the printout into one file

by sabas (Novice)
on Nov 15, 2018 at 01:07 UTC ( #1225831=perlquestion: print w/replies, xml ) Need Help??

sabas has asked for the wisdom of the Perl Monks concerning the following question:

Can i ask a favor if I can have a perl script to login ssh into multiple servers and execute a command like "df -h" and have the printout written into one log file. example: 10 servers, and the 10 printout of those 10 servers using df -h command will be appended into one file. Thank You and appreciate your help.

  • Comment on df -h script to 10 servers and append the printout into one file

Replies are listed 'Best First'.
Re: df -h script to 10 servers and append the printout into one file
by kcott (Bishop) on Nov 15, 2018 at 05:38 UTC
Re: df -h script to 10 servers and append the printout into one file
by salva (Abbot) on Nov 15, 2018 at 15:07 UTC
    Congratulations, you have won the following dirty one-liner as part of the monastery pre Black Friday give away!!!
    perl -e 'system(qq(ssh $_ "hostname && df -h")) for @ARGV' host1 host2 + host3 ...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1225831]
Approved by kcott
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2020-11-25 02:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?