Daniel Falkenberg wrote:
>
> Curtis,
>
> Cheers for that that makes alot more sense now :). Yes your are correct
> about the /etc/passwd file. It's all well and good to be able to issue
> that command from a command line, but what if I wanted to issue the
> exact same code but from a script?
First a warning. If you mess with the /etc/passwd file in a multi-user
environment you could screw up your system.
#!/usr/bin/perl -w
use strict;
my $passwd = '/etc/passwd';
my $backup = '/etc/passwd-old';
rename $passwd, $backup or die "Cannot rename $passwd: $!";
open PWI, "< $backup" or die "Cannot open $backup: $!";
open PWO, "> $passwd" or die "Cannot open $passwd: $!";
while ( <PWI> ) {
next unless (split /:/)[3] == 45;
s/^/*/;
print PWO;
}
unlink $backup or warn "Cannot delete $backup: $!";
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]