As promised in my last mail wanting help, I've been reading up on perl nd
having a go and playing with a script sent to me by Raphael (Many thx) ....
Now my problem is, for some reason, in my virtual user table, there are space
and tab's, how do I get the split to recognise the tab as well as the space
char?
my @fields = split(" ", $_); # Break it down, this is the original and
sees the space ok...
my @fields = split(" ", $_) || split("<ascii for tab?", $_); # Break it
down, is this anywhere close ?
What I'm aiming for is a script that I can add/modify or delete entries in
the virtual usertable.....
I can get the entries added without any problems, but I will probably be
posting again at some time to get help on modifying and deleteing them...
#! /usr/bin/perl -w
# make sure we get command line args
if (not(defined($ARGV[0]))) {
print "\n\n\nUsage: chk_alias <username>\n\n\n";
exit(1);
}
my $username = $ARGV[0]; # Get the username from commandline
chomp($username);
open(VUT, "</etc/mail/virtusertable")|| die "Cannot read virtusertable\n";
while (<VUT>) { # Read a line from /etc/mail/virtusertable
my @fields = split(" ", $_); # Break it down
my $alias = $fields[0];
my $user = $fields[1]; # User name
chomp($user);
next unless $user eq $username;
print "Alias for $username is $alias\n";
}
close VUT;