Results 1 to 4 of 4
  1. #1
    Join Date
    May 2010
    Posts
    1

    Unanswered: system command fails after connecting to oracle using DBI

    After I successfully connect to oracle (OS authentication), system command runs fine but it return error code and fails. Does anyone has face this problem ?

    === Script ===
    #!/usr/bin/perl -v

    my $dbh;
    if ( system ("pwd") )
    {
    print "Error!!!!!!!!\n";
    }

    $dbh = DBI->connect('dbi:Oracle:','/','');
    print "DB Ping result : ".$dbh->ping."\n";

    if ( system ("pwd") )
    {
    print "Error!!!!!!!!\n";
    }
    print "DB Ping result : ".$dbh->ping."\n";

    === Script Output ====
    PRINT CURRENT DIRECTORY [1st system command]
    DB Ping result : 1 [DB connection is fine ]
    PRINT CURRENT DIRECTORY [2nd system command]
    Error!!!!!!!! [2nd system command returned failure]
    DB Ping result : 1 [DB connection is still fine ]

    === Perl/ DBI Version ===
    /usr/bin/perl -v
    This is perl, v5.8.4 built for sun4-solaris-64int

    /usr/bin/perl -MDBI -le 'print $DBI::VERSION'
    1.609



    Any help is highly appreciated.


    Thanks
    Ritesh

  2. #2
    Join Date
    Oct 2002
    Location
    Baghdad, Iraq
    Posts
    697
    Code:
    $dbh = DBI->connect('dbi:Oracle:','/','');
    print  "DB Ping result : ".$dbh->ping."\n";
    
    if ( system ("pwd") )
    {
        print "Error!!!!!!!!\n";
    }
    print  "DB Ping result : ".$dbh->ping."\n";
    I never really use the ping method, and it may return a good value when there is still a problem. If you want to test for errors, use $h->err or $h-errstr, see The Fine Manual for more info.

    All system("pwd") does is calls a subshell to attempt to get the present working directory, or whatever the "pwd" executable in your current path does.

    You need to figure out where the call is failing. First, make sure you run all your tests with the -w flag to enable warnings. Here are some further tests you can do:

    You might try to verify that your working directory is actually valid.

    Code:
    use Cwd;
    
    print getcwd;
    That should make the same system call that pwd does, but without running a subshell.

    Then try to see if a subshell works. test true should always return 0.

    Code:
    rc = system("test", "true");
    print(rc, " ", rc >> 8, "\n");
    That should return 0 0, with the second value being the actual return code.

    You can also try to see if the subshell is working, but the fork is failing.

    Code:
    exec('pwd');
    # Exec will quit your program at this point.
    You're just looking for possible error messages. Again, make sure you run with -w.

  3. #3
    Join Date
    Aug 2010
    Posts
    1

    Did you find a solution to your problem ?

    Hi Maharaja,
    Did you find a solution to your problem?
    If yes, what is it?
    In advance thank you

    --------------------------------

    Quote Originally Posted by maharaja View Post
    After I successfully connect to oracle (OS authentication), system command runs fine but it return error code and fails. Does anyone has face this problem ?

    === Script ===
    #!/usr/bin/perl -v

    my $dbh;
    if ( system ("pwd") )
    {
    print "Error!!!!!!!!\n";
    }

    $dbh = DBI->connect('dbi:Oracle:','/','');
    print "DB Ping result : ".$dbh->ping."\n";

    if ( system ("pwd") )
    {
    print "Error!!!!!!!!\n";
    }
    print "DB Ping result : ".$dbh->ping."\n";

    === Script Output ====
    PRINT CURRENT DIRECTORY [1st system command]
    DB Ping result : 1 [DB connection is fine ]
    PRINT CURRENT DIRECTORY [2nd system command]
    Error!!!!!!!! [2nd system command returned failure]
    DB Ping result : 1 [DB connection is still fine ]

    === Perl/ DBI Version ===
    /usr/bin/perl -v
    This is perl, v5.8.4 built for sun4-solaris-64int

    /usr/bin/perl -MDBI -le 'print $DBI::VERSION'
    1.609



    Any help is highly appreciated.


    Thanks
    Ritesh

  4. #4
    Join Date
    Oct 2010
    Posts
    1
    it is a little different to me to understand,
    buy wow gold
    wow gold
    cheap wow gold
    ffxiv gil
    wow gold
    game news

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •