If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Perl and the DBI > system command fails after connecting to oracle using DBI

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-04-10, 01:28
maharaja maharaja is offline
Registered User
 
Join Date: May 2010
Posts: 1
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
Reply With Quote
  #2 (permalink)  
Old 05-12-10, 09:55
sco08y sco08y is offline
Registered User
 
Join Date: Oct 2002
Location: Baghdad, Iraq
Posts: 696
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.
Reply With Quote
  #3 (permalink)  
Old 08-06-10, 06:03
LOTITO LOTITO is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 10-12-10, 00:20
Cheneyhappy Cheneyhappy is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On