Hey, why not.  It's always nice to see how other people think.

Would something like this be needed, kill all <insert program here>

kill `ps -ef | grep <insert program here> | awk '{ print $2}'`

or 
Better yet, Read CSV File, create Temp Table in MYSQL.

#!/usr/bin/perl


use DBI;
use Data::Dumper;

my $dsn = 'dbi:mysql:<DB_NAME>:localhost:3306';

# set the user and password
my $user = '<USER>';
my $pass = '<PASSWD>';

# now connect and get a database handle
my $dbh = DBI->connect($dsn, $user, $pass) or die "Can't connect to the
DB: $DBI::errstr\n";

$TABLE_NAME = @ARGV[0];
$TABLE_NAME =~ s/\.csv$//i;

$TITLES = <>;
chomp $TITLES;
@TITLES = split (/,/,$TITLES);


$Drop_SQL = "DROP TABLE $TABLE_NAME";
$Drop_STH=$dbh->prepare($Drop_SQL);
$Drop_STH->execute;


$SQL = "CREATE TABLE $TABLE_NAME (";
foreach $title (@TITLES) {
        $SQL .= "$title VARCHAR(100),";
}
$SQL .= ") ";

$Createtable = $dbh->prepare($SQL);
$Createtable->execute;

$Insert_SQL = "INSERT INTO $TABLE_NAME VALUES(" . "?," x (@TITLES -1) .
?)";

$Insert_STH = $dbh->prepare($Insert_SQL);
while (<>) {
        chomp;
        @Data = split(/,/);
        $Insert_STH->execute(@Data);
}



--Jimmy

=+=+=+=+=+=+=+=+=+=+
James Schappet
Schappet.com


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Michael A Nachbaur
Sent: Monday, September 29, 2003 12:55 PM
To: [EMAIL PROTECTED]
Subject: [Perl-unix-users] RFC: Unix Sysadmin perl snippets

Hello everyone,

I do system administration and programming, and I rely heavily on Perl
to do 
both these duties.  I find that, in the course of my work, I routinely
create 
one-off scripts - snippets of perl code, one-liners, etc - that I use to

short-cut around some of the messier aspects of my job.

Most of these scripts when I'm done with them just get deleted in my 
all-too-infrequent home directory cleanups, or scroll off my
~/.bash_history.

Would anyone in this list be interested in recieving cookbook-style
sample 
routines?  I know some newbies hang out here, and might appreciate
seeing how 
other sysadmins go about their work.  I'm sure other experts in this
list 
might have something they can contribute, even if it's just a "Wow, this
is 
neat" or a "Aren't I cool?  This just saved me six hours of work" sort
of 
email.

Thoughts? Comments?

-- 
/* Michael A. Nachbaur <[EMAIL PROTECTED]>
 * http://nachbaur.com/pgpkey.asc
 */

"One's never alone with a rubber duck. "

_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to