I am facing a strange problem with perl code. I have a perl package abc.pm which has following subroutine:
sub DB_xxx { my ($dbUser, $dbPass, $db, $autoCommit) = @_; my $dbh; # logon to DB unless( $dbh = DBI->connect('dbi:Oracle:' . ($$db || ''), $$dbUser +, $$dbPass, {AutoCommit => $$autoCommit}) ) { croak "Error connecting to database $DBI::errstr \n"; } return $dbh; }

This method is for connecting to database

Inside my own .pl file I am using this subroutine in following manner:
use abc qw (DB_xxx); my $dbh; my $stat1 = system ("gzip -t xyz.gz"); print "The stat checking:$stat1\n"; my $userid = xxx; my $passwd = xxx; my $database = xyz; my $autocommit = 0; $dbh=DB_xxx(\$userid, \$passwd, \$database, \$autocommit); my $stat2 = system ("gzip -t xyz.gz"); print "The stat checking:$stat2\n";

The problem is:the value of $stat1 is 0 but value of $stat2 is -1. though the .gz file is same in same location. In Solaris 8 box but in $stat1 & $stat2 have values 0 for both. But in solaris 10 box giving to two differnt output:$stat1=0 & $stat2=-1

I have also printed $!: For $stat2 it is showing error message: / No child process/

Can anybody please help me? Please it is urgent.


In reply to system function is returning status -1 when running a unix command by elf_firein

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.