Ethen,
Have you looked at system? However, is there a particular reason why are you interacting with Oracle in this manner? I would suggest taking a look at DBI which is (unless there is a reason why you want to run the exe with arguments) a better way or interfacing with your database, depending on what you want to do.
Hope this helps
Martin | [reply] |
Hmm, I've got more comments than just an answer to your question.
my ($sec,$min,$hour,$day,$month,$yr19,@rest) = localtime(time);#####
##To get the localtime of your system
print "Date:\t$day-".++$month. "-".($yr19+1900)."\n"; ####To print dat
+e format as expected
print "Time:\t".sprintf("%02d",$hour).":".sprintf("%02d",$min).":".spr
+intf("%02d",$sec)."\n";###To print the current time
Why are you not simply using strftime in POSIX? It is like using sprintf but for date and time formats. It can format the time any way you want without you having to tweak the fields from localtime, first.
And even if you decide not to, it's still clearer to use a single sprintf (or printf) call, instead of concatenating results of several calls.
printf "Time:\t%02d:%02d:%02d\n", $hour, $min, $sec;###To print the cu
+rrent time
$SQLPLUS = "C:/sqlplus.exe";
You're hardcoding a single location, instead of letting Windows find it in your PATH.
You can check if it exists by using:
$version = `sqlplus -V`;
Either that will succeed, putting a string with a version number in $version, or it'll fail, returning undef and probably setting $? too to a nonzero value.
If you insist of finding exactly where SQLPLUS is, take a look at `which` (for Windows) in pure perl, which implements a Pure Perl snippet for finding an executable in PATH.
The code to run the sqlplus.exe.......shoud be here
Like I showed just above, you can use backticks (AKA qx), which will capture the STDOUT of the program; you call system which will let STDOUT go its usual way; or you can use one of a few modules, like IPC::Open2, IPC::Open3, IPC::Run. You can even use open with a trailing "|" after the command line, to read STDOUT from the running program. Oh, and on Windows, you can use Win32::Process too, which will not wait for the invoked program to finish, to resume execution of your script. Choices, choices... | [reply] [d/l] [select] |
system( $SQLPLUS ) == 0 or die $?;
Or, if you want to capture the output of the program use backticks, or the qx{} equivalent.
my $output = qx{ $SQLPLUS };
| [reply] [d/l] [select] |
Thank you Perl Monks, you shared your wisdom -> I have solved many problems just looking at posted threads and tutorials.
Here is my question: I run an executable from the DOS-like command line, just as the guy who started this thread.
The problem is that I have to start it many times (running the same executable) and each time the exe command will take a different time to perform its task.
I have to run the exe for a fixed, known number of times. This means that I need PERL commands to
(1) run the file from command line (ok, I got it...)
(2) check if the exe has finished the work
(3) if yes, go back to (1)
| [reply] |
| [reply] |
Actually I discovered it just a few moments after posting the topic... :-|
Thank you anyway :-)
| [reply] |