I've got the perl function for adding new users to my Linux system working.
The code is below. Now I would like to clean it up a little. How can I check
the completion code of the useradd function and print out error completion
codes and error messages? Also why does the ; terminating the useradd call
have to be on the next line (It doesn't work if it is on the same line). I am
well pleased to have this working. Thanks to everyone who help me piece it
together.

Regards.  Paul



# Heres an example of how to override the database insertion function
# so that when you add a new user, it automatically
# adds them to your Unix system too:

BEGIN

    # Remember pointers to functions we are going to override
    $Radmin::Site::original_insert = \&Radmin::DBSQL::insert;


sub Radmin::DBSQL::insert

    my ($self, $obj) = @_;

    if ($obj->{Type} eq 'RADUSERS')
    {
        # Adding a new entry to the user list
        `/usr/sbin/useradd -c \"$obj->{FULLNAME}\" $obj->{USERNAME}`
             ;
        #
        # Set up the new users password
        # 
        open(CHANGEPASSWORD,"|/usr/sbin/chpasswd");
        print CHANGEPASSWORD "$obj->{USERNAME}:$obj->{PASS_WORD}\n";
        close(CHANGEPASSWORD);
    }
    &$Radmin::Site::original_insert($self, $obj);

===
Archive at http://www.thesite.com.au/~radiator/
To unsubscribe, email '[EMAIL PROTECTED]' with
'unsubscribe radiator' in the body of the message.

Reply via email to