Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: parse /etc/passwd and output it as csv in hundred servers

by diotalevi (Canon)
on Apr 16, 2018 at 03:32 UTC ( [id://1212961]=note: print w/replies, xml ) Need Help??


in reply to parse /etc/passwd and output it as csv in hundred servers

Hi, you could solve this in perl alone but this is also a practical use for parallel-ssh with a snip of perl to make your report.

apt install pssh parallel-ssh -h HOSTNAMES_TXT -o /tmp/users 'cut -d: -f1 /etc/passwd' perl -le ' for my $file (@ARGV) { my ($host) = $file =~ m{/([^/]+)$}; open my($fh), $file or die "Error opening $file: $!"; my @users = <$fh>; chomp @users; print join(",", $host, @users) . "\n"; } ' /tmp/users/*

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1212961]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-24 20:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found