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

In reply to Re^4: backup for the users on the system in linux enviroment by hummty_dummty
in thread backup for the users on the system in linux enviroment by hummty_dummty

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.