Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl script stopped working after migration of SQL database to a VM

Status
Not open for further replies.

Apache65

Technical User
Jan 30, 2006
16
We have been using a Perl script to call a stored procedure on a SQL database to fetch data and build an html page on our intranet. The server running the database crashed and was rebuilt on a virtual machine. Ever since the database was put on a VM, this script hasn’t worked. The only thing that is returned is a blank (white) html page. Are there any known issues using Perl to fetch data from a database running on a VM then build an html webpage?
 
Thanks for your reply Keith. Yes, however, the VM server and database names are the same as before. They were created using a backup, from the night before the old server crashed.

I did create a new ODBC system dsn on our webserver, along with a new user/password on the database side but when the script, the only thing returned is a blank (white) html page.

The script actually gets its variables from an html form that executes the script. I didn't see anything in the from that passes username/password to the database.

Below is the script that has been in place since 2009. The two stored procedures that get called do have read/write and execute permissions for the user.
______________________________________________________

##Version 5.27.03 Live on Webserver. Displays info and pictures.
#02/17/09 Modified to add Sponsoring Physician (job_title)-aap
#!/usr/local/bin/perl
use strict;
use CGI qw:)all);
#use CGI::CARP qw(fatalsToBrowser);
use Win32::ODBC;

#declare variables
my ($name, $value, $photo, $image, $sql);
my $path = "/DocImages/";
my $filepath = "C:\\Inetpub\\my $CGI = new CGI();
my $q = new CGI;

print header;

#Get form values
$name = $q->param( 'SearchBy' );
$value = $q->param( 'Criteria' );
#Format value for SQL search
$value = $value . '%';
#call requisite stored procedure for the calling paramater
if ($name eq 'Last Name')
{
$sql = "{call pr_Learning( '$value')}";
}
else
{
$sql = "{call pr_ID( '$value')}";
}
#build connection to database
my $DSN = shift @ARGV || "INFO";

##Webserver handle
my $db = new Win32::ODBC( "DSN=WebMedCred;UID=username;PWD=password");
if( ! $db )
{
die "Error connecting: " . Win32::ODBC::Error() . "\n";
}

#call the procedure
$db->Sql($sql);

##HTML display
print $q->start_html(-title=>'Parkview Physicians',
-BGCOLOR=>'white'),
h3('Physician Information'),
table({-border=>0, -cellspacing=>2});
print "<tr><TD><a href=/MedStaffSearch.htm>New Search</a></TD></TR>";
#fetch and display result set
while ($db->FetchRow())
{
my %Data;
%Data= $db->DataHash();

#Determine if the image file exists, display photo if yes, Default photo if no
$photo=$Data{dr_mnc}.'.jpg';
my $fn = $filepath.$photo;
if (-e $fn) {
$image = "$path$photo";
}
else {
$image = $path."DefaultPhoto.gif";
}
print <<HTML;
<TR>
<TD colspan="2" bgcolor="#99CCCC"><b>$Data{first_nm} $Data{last_nm}, $Data{title} | Mneumonic: $Data{dr_mnc} | Doctor Number: $Data{doc_nbr}<br>Sponsoring Physician: $Data{job_title}</b></TD>
</TR>
<TR>
<TD>$Data{street}<br>$Data{city}, $Data{state} $Data{zip}</TD>
<TD rowspan="8"><img src = $image></TD></TR>
<TR>
<TD>Phone: $Data{phone}</TD>
</TR>
<TR>
<TD>Fax: $Data{fax}</TD>
</TR>
<TR>
<TD>Pager: $Data{pager}</TD>
</TR>
<TR>
<TD>Department: $Data{dept}</TD>
</TR>
<TR>
<TD>Specialty: $Data{spclty}</TD>
</TR>
<TR>
<TD>Staff Status: $Data{status}</TD>
</TR>
<TR><TD>Admit Patients: $Data{admit}</TD>
</TR>
<TR><TD>Sponsoring Physician: $Data{admit}</TD>
</TR>
<TR colspan="2">
<TD><form name="priv" method="post" action="/cgi-bin/priv.pl">
<input type="submit" name="Submit" value="View Privilege List">
<input type="hidden" name="Criteria" value="$Data{dr_mnc}"></FORM></TD>
</TR>

<TR colspan="2"><TD colspan="2"><hr width=100%></TD></TR>
HTML

}
print "</TABLE></BODY></HTML>";
$db->Close();
 
Code:
my $db = new Win32::ODBC( "DSN=WebMedCred;UID=username;PWD=password");
Have you changed this line to post here?
Does the script run when called directly?

Keith
 
Figured it out.... when our network engineers created the new VM they did not configure the "Named Pipes", under the SQL Server Client Network Utility, correctly. It was set as \sql\query.

Once we changed it to \\MEDCRED\pipe\sql\query the script ran as expected. Thank for your help….
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top