in reply to Re: SQLPLUS connect database
in thread SQLPLUS connect database

Using a fixed filename can potentially cause problems if there are multiple processes, and a relative filename can cause problems if the user doesn't have write access in that directory. I'd recommend using File::Temp (a core module):

use File::Temp qw/tempfile/; my ($tfh,$tfn) = tempfile(UNLINK=>1); print $tfh <<'END_OF_SQL'; SET HEADING OFF; SELECT systimestamp || ' IP=' || sys_context('USERENV','IP_ADDRESS') FROM dual; EXIT END_OF_SQL close $tfh; # the filename is in $tfn # no "unlink" needed, that's automatic

I showed some more common File::Temp patterns that I use, such as creating the files in a specific directory, in this node. And because the above requires putting a variable into the external command being run, I'd recommend using a module to do that, such as e.g. capturex from IPC::System::Simple (see my node here).