Last change
on this file since 572 was
572,
checked in by nanardon, 15 years ago
|
- add tools to fetch passwd and merge it into passwd file
|
File size:
1.3 KB
|
Line | |
---|
1 | #!/bin/env perl |
---|
2 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | use File::Temp qw(tempfile); |
---|
6 | |
---|
7 | my %jpass; |
---|
8 | |
---|
9 | sub set_pass { |
---|
10 | my ($user, $pass) = @_; |
---|
11 | $pass eq 'x' and return; |
---|
12 | $pass eq '!!' and return; |
---|
13 | $pass eq 'CLOSED' and return; |
---|
14 | $jpass{$user} ||= $pass; |
---|
15 | } |
---|
16 | |
---|
17 | |
---|
18 | my $ssh1 = open (my $fh, "ssh thauvin\@sirocco.aero.jussieu.fr 'ypcat passwd' |") or die "can't ssh sirocco"; |
---|
19 | while (my $line = <$fh>) { |
---|
20 | chomp($line); |
---|
21 | my @ch = split(':', $line); |
---|
22 | set_pass $ch[0], $ch[1]; |
---|
23 | } |
---|
24 | close($fh) or die "ssh exit with error on sirroco"; |
---|
25 | |
---|
26 | |
---|
27 | my $ssh3 = open (my $sfh, "ssh thauvin\@savtcp.aerov.jussieu.fr 'ypcat passwd' |") or die "can't ssh savtcp"; |
---|
28 | while (<$sfh>) { |
---|
29 | chomp; |
---|
30 | my @ch = split(':', $_); |
---|
31 | set_pass $ch[0], $ch[1]; |
---|
32 | } |
---|
33 | close($sfh) or die "ssh exit with error on savtcp"; |
---|
34 | |
---|
35 | my $ssh2 = open (my $pfh, "ssh thauvin\@python.latmos.ipsl.fr 'ypcat passwd' |") or die "can't ssh python"; |
---|
36 | while (my $line = <$pfh>) { |
---|
37 | chomp($line); |
---|
38 | my @ch = split(':', $line); |
---|
39 | set_pass $ch[0], $ch[1]; |
---|
40 | } |
---|
41 | close($pfh) or die "ssh exit with error on python";; |
---|
42 | |
---|
43 | require Data::Dumper; |
---|
44 | warn Data::Dumper::Dumper { var => \%jpass }; |
---|
45 | |
---|
46 | open (my $lpfh, '<', 'passwd') or die "Can't open passwd"; |
---|
47 | while (my $line = <$lpfh>) { |
---|
48 | chomp($line); |
---|
49 | my @var = split(':', $line); |
---|
50 | $var[1] = $jpass{$var[0]} || 'x'; |
---|
51 | $var[5] = "/net/nfs/home/$var[0]"; # Force home directory |
---|
52 | print join(':', @var) . "\n"; |
---|
53 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.