Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: backup for the users on the system in linux enviroment

by cengineer (Pilgrim)
on Jun 18, 2007 at 14:19 UTC ( #621795=note: print w/replies, xml ) Need Help??


in reply to Re^2: backup for the users on the system in linux enviroment
in thread backup for the users on the system in linux enviroment

as far as those error messages go - you're using strict mode, but you're not declaring:
my $file; my @columns;

Replies are listed 'Best First'.
Re^4: backup for the users on the system in linux enviroment
by hummty_dummty (Initiate) on Jun 19, 2007 at 00:27 UTC

    hello all monks finally i did it and i wrote that script tahnks for all who help me


    #!/usr/bin/perl -w use strict; use DBI; use diagnostics; #step1 - create connection objection . my $dsn = 'DBI:mysql:backupDB'; my $user = 'adam'; my $password = 'secret'; my $conn = DBI->connect($dsn,$user,$password) || die "Error connecting +" . DBI->errstr; my $file = "/etc/passwd"; open (han1, "$file") || die "error opening file: $!"; my @newrecords = <han1>; foreach (@newrecords) { my @columns = split /:/; my $username = $columns[0]; my $x = $columns[1]; my $userid = $columns[2]; my $groupid = $columns[3]; my $realname = $columns[4]; my $homedir = $columns[5]; my $shellpath = $columns[6]; $conn->do("insert into users(username,x,userid,groupid,realname,homedi +r,shellpath) values('$username','$x','$userid','$groupid','$realname' +,'$homedir','$shellpath')") || die "error preparing query" . $conn->e +rrstr; }

    the last thing i want to know is how can i make this operation updated i mean if i add new user for example how can i make the program to fetch the new records and add to the database

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://621795]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2023-12-07 12:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (32 votes). Check out past polls.

    Notices?