in reply to How to run a .exe file from a Perl script?
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.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
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
You're hardcoding a single location, instead of letting Windows find it in your PATH.$SQLPLUS = "C:/sqlplus.exe";
You can check if it exists by using:
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.$version = `sqlplus -V`;
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.
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...The code to run the sqlplus.exe.......shoud be here
|
|---|