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

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

by diotalevi (Canon)
on Apr 16, 2018 at 03:32 UTC ( #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
Node Status?
node history
Node Type: note [id://1212961]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2019-05-23 00:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (140 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!