hummty_dummty has asked for the wisdom of the Perl Monks concerning the following question:
iwant to make backup for the users on the system in linux enviroment
here is my code it gave me lot of errors any body helps me in solving this problem please
#!/usr/bin/perl -w use strict; use DBI; #step1 - create connection objection . my $dsn = 'DBI:mysql:contacts'; my $user = 'adam'; my $password = 'secret'; my $conn = DBI->connect($dsn,$user,$password) || die "Error connecting +" . DBI->errstr; $file = "/etc/passwd"; open (han1, "$file") || die "error opening file: $!"; my @newrecords = <han1>; foreach (@newrecords) { @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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: backup for the users on the system in linux enviroment
by ysth (Canon) on Jun 18, 2007 at 00:04 UTC | |
by hummty_dummty (Initiate) on Jun 18, 2007 at 00:47 UTC | |
by ysth (Canon) on Jun 18, 2007 at 01:22 UTC | |
by cengineer (Pilgrim) on Jun 18, 2007 at 14:19 UTC | |
by hummty_dummty (Initiate) on Jun 19, 2007 at 00:27 UTC |