Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Perl script to wait till the command execution completes.

by pradeep,krishna (Scribe)
on Mar 03, 2014 at 08:47 UTC ( #1076756=perlquestion: print w/ replies, xml ) Need Help??
pradeep,krishna has asked for the wisdom of the Perl Monks concerning the following question:

Hello fellow monks.
I am using bellow code to check for sqlplus connectivity.

my $ConnString = "SQLPLUS -L " . $Login_Name . "\/" . $Login_Password +. "\@" . $DB_Name . " \@sqlfile.sql"; my $ReturnCode=system($ConnString); sleep(2); #--Give time to autheticate. if ($ReturnCode!=0) { print scalar (localtime)," E: SqlPlus Database Login unsuccessful +l.\n"; return -1; } print LOG_FILE scalar (localtime)," I: SqlPlus Database Login succe +ssfull.\n";


Here 'sqlfile.sql' contains only 'exit' statement in it.

Some times in the execution it takes more than 2 seconds to complete because of network traffic.
So including sleep(2); will be not enough some times. I want to make sleep time of my script dynamic.

Thanks in advance.

Pradeep Krishna :)

Comment on Perl script to wait till the command execution completes.
Select or Download Code
Re: Perl script to wait till the command execution completes.
by marto (Chancellor) on Mar 03, 2014 at 09:14 UTC

    What are you actually trying to achieve? Is there a reason you are not using DBI/DBD::Oracle to work with your database?

      As i have mentioned, I am using This code to check for sqlplus connectivity.

Re: Perl script to wait till the command execution completes.
by hippo (Curate) on Mar 03, 2014 at 09:26 UTC

    system() waits until the command completes anyway. If yours isn't it may be because you are not escaping the values passed to it. If any of your variables such as $Login_Password has an unescaped ampersand, for example, you are going to run into problems.

    You could fix this, but marto's suggestion of using DBI would be a far better approach in the first place.

Re: Perl script to wait till the command execution completes.
by zentara (Archbishop) on Mar 03, 2014 at 12:08 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1076756]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-10-02 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (52 votes), past polls