Hi, I am new here and i have a problem with my perl script. The scripts gets 3 columns of data from an oracle database, and passed 2 columns throught to a mysql sub. This sub then puts the data into an Mysql database. When this script is run direclty on the promt everything works fine. When run as a cron the seconds column gets corrupted somehow. All the numbers are xxx instead of the original numbers, sometimes the columns are just skipped. This is the code i made (not the best in the world i know):
#!/usr/bin/perl $ENV{'ORACLE_HOME'} = '/prog/oracle/10.2.0'; use DBI; use Mysql; use strict; #############MYSQL############### sub sub_mysql { my $myhost = "localhost"; my $mydatabase = "db"; my $mytablename = "table"; my $myuser = "user"; my $mypwd = "password"; my $myconn = Mysql->connect($myhost, $mydatabase, $myuser, $mypwd); $myconn->selectdb($mydatabase); my $myquery = "INSERT INTO $mytablename (date, status, well) VALUES (N +OW(),'$_[0]','$_[1]')"; my $myexecute = $myconn->query($myquery); } ###############END MYSQL################ ##############ORACLE SQL############## my $orahost = "oracle.bla.com"; my $oraport = "1000"; my $orasid = "I01"; my $orauser = ""; my $orapwd = ""; my $oraconn = "dbi:Oracle:HOST=$orahost;SID=$orasid;port=$oraport"; my $db = DBI->connect( $oraconn, $orauser, $orapwd ) || die( $DBI::err +str . "\n" ); my $oraquery = "SELECT date, status, well FROM bla where > sysdate -1 "; my $sth = $db->prepare($oraquery); $sth->execute(); my ($date, $well, $status); $sth->bind_columns(\$date, \$well, \$status); while( $sth->fetch() ) { sub_mysql("$status","$well"); } $db->disconnect; #############END ORACLE SQL#############
*please ignore the bad oracle sql statement* Hopefully someone knows what is going on..?

In reply to Perl script not running correct as a cron by lars_4

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.