Smaug has asked for the wisdom of the Perl Monks concerning the following question:
$VAR1 = '1';<BR> $VAR2 = undef;
use strict; use DBI; use Data::Dumper; use Getopt::Long qw (GetOptions); my $help = "0"; my $server = "0"; my $user = "0"; my $password = "0"; #Set the options for GetOpt Getopt::Long::Configure( "pass_through", "no_ignore_case", "prefix_pat +tern=(-|\/)" ); #What to expect on the command line my %opts = (); my %opts=(GetOptions( 'help|?' => \$help, 'server' => \$server, 'user' => \$user, 'password' => \$password )); print Dumper(%opts); #DEBUG: See what's there if($opts{help}) { &Help; } my $mytime=(time); my $database="TNGDB"; #Start Logging to log file.. open (LOGF, ">>%0../../$mytime.log") || die "Could not open the Log Fi +le: $!\n"; #Connect to MSSQL Server my $dsn="driver={SQL Server};Server=$server;database=$database;UID=$us +er;PWD=$password;"; my $dbh=DBI->connect("dbi:ODBC:$dsn", $user, $password) || die &Logger +("...Unable to connect. Reason: $DBI::errstr"); &Logger ("...Success: connected to database $server\\$database\n"); #Get Data #Insert the select statements here.... $sth->finish(); $dbh->disconnect(); ######################################## ## SUBS ## ######################################## # Message Logging sub Logger { my $text = shift; my $rc = 0; if (print LOGF "$text\n") { $rc=1; } return ($rc); } #CLI Help sub Help { print "Invalid option.\n","The valid options are: \n"; print "MakeCVM.exe -h (or ? or help) displays this.\n"; print "MakeCVM.exe -server=<Server> -user=<SQL User> -password=<Pa +ssword>"; }
DBI connect('driver={SQL Server};Server=0;database=TNGDB;UID=0;PWD=0;' +,'0',...) failed: at E:\MakeCVM\makeCVM-SQL.pl line 41 1 at E:\MakeCVM\makeCVM-SQL.pl line 41.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Battling Getopt::Long
by Tomte (Priest) on May 11, 2004 at 12:33 UTC | |
by Smaug (Pilgrim) on May 11, 2004 at 12:53 UTC | |
by Tomte (Priest) on May 11, 2004 at 12:57 UTC | |
|
Re: Battling Getopt::Long
by Abigail-II (Bishop) on May 11, 2004 at 12:32 UTC | |
|
Re: Battling Getopt::Long
by eserte (Deacon) on May 11, 2004 at 12:37 UTC | |
|
Re: Battling Getopt::Long
by AcidHawk (Vicar) on May 11, 2004 at 15:25 UTC | |
by Smaug (Pilgrim) on May 12, 2004 at 08:48 UTC | |
|
Re: Battling Getopt::Long
by Anonymous Monk on May 11, 2004 at 13:40 UTC | |
by Abigail-II (Bishop) on May 11, 2004 at 13:44 UTC |