[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 314
  • Last Modified:

Help with a script

I have not used Perl in a long while and need to debug a small script.
use Sybase::CTlib;
use FileHandle;
use Net::FTP;
use Net::FTP::Common;

$DBSERVER='DSRFCNYU01';
$DBUSER='Risk_Feed';
$DBPWD='R1sk_Feed';
$DB='SDAPS';
($sec,$min,$hr,$mday,$mon,$year,$wd,$yd,$isdst)=localtime(time);
$year = $year - 0 + 1900;
$mon = $mon - 0 + 1;
$delim = "|";
$dbname = "SDAPS";
$dbh = new Sybase::CTlib $DBUSER, $DBPWD, $DBSERVER;

$dbh->ct_execute("select convert(varchar,max(entrydate),112) as rundate from $dbname..fxrates");
while($dbh->ct_results($restype) == CS_SUCCEED) {
   next unless $dbh->ct_fetchable($restype);
   while(@dat = $dbh->ct_fetch) { $rundate=$dat[0];}      
}  

Now from my limited memory, this sets up a connection to a Sybase database and retrieves a date into a variable $rundate. How can I check if the connection is established? What is a syntax for a message box?
0
leonstryker
Asked:
leonstryker
1 Solution
 
Perl_DiverCommented:
this line:

$dbh = new Sybase::CTlib $DBUSER, $DBPWD, $DBSERVER;

might be better written as:

$dbh = Sybase::CTlib->new( $DBUSER, $DBPWD, $DBSERVER)

I'm not familiar with the module but you can always read the docs online if you don't have a local copy to read:

http://search.cpan.org/~mewp/sybperl-2.18/CTlib/CTlib.pm;

There is a section called "general information" that discusses error handling.

I don't know what you mean by: "what is a syntax for a message box?".
0
 
leonstrykerAuthor Commented:
>I don't know what you mean by: "what is a syntax for a message box?".

Hmm, I am running this on NT with WSH so I was hoping to bring up a message box with the value of a variable, just to see its contents.
0
 
Adam314Commented:
To see the value of a variable, i usually use print.  This way, you can redirect STDOUT, and have file showing everything:
script.pl > output.txt

But, if you want a message box:
put this at the top:
    use Win32;

Then use this to display a message box
    Win32::MsgBox("Variable=$var");
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now