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_pattern=(-|\/)" ); #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 File: $!\n"; #Connect to MSSQL Server my $dsn="driver={SQL Server};Server=$server;database=$database;UID=$user;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= -user= -password="; }