HI Gustaf
I'd guess this is not a Windows thing, as I can reproduce the problem in
standard TCL on both Windows and Linux. But I haven't looked at Naviserver on
Linux to confirm it there.
This worked fine for years in AOLserver on both Windows and Linux. It seems to
be that Naviserver's version of "open" is closer to the standard TCL version.
When should I write the "exit\n" to the pipe? I've tried a few variations on
the following with no success:
set fp [open "|[file join $::env(ORACLE_HOME) bin sqlplus] $user_pass @$file"
"r+"]
puts $fp "exit\n"
while { [gets $fp line] >= 0 } {
append output $line
}
close $fp
thanks
Brian
From: Gustaf Neumann [mailto:neum...@wu.ac.at]
Sent: 20 February 2017 12:48
To: naviserver-devel@lists.sourceforge.net
Subject: Re: [naviserver-devel] Differences in usage of "open" command between
Naviserver and AOLserver
Hi Brian,
I am not sure, how this ever worked, ... and maybe there is a big difference in
the end-of-file treament of sqlplus under windows, but altering the tcl command
"open" does not look right (this is used for all "open" operations).
Doesn't the anwer in
http://serverfault.com/questions/87035/run-oracle-sql-script-and-exit-from-sqlplus-exe-via-command-prompt
help? (writing "exit\n" to the pipe, open pipe with "r+")?
-g
Am 20.02.17 um 13:01 schrieb Brian Fenton:
Hi all
We're in the early stages of an attempt to migrate from AOLserver to
Naviserver. For now, we're just looking at the Windows version of Naviserver,
but I guess this might be an issue on Unix versions too.
We've already run into an issue with some OpenACS code that that uses "open" to
open a pipe to Oracle's SQL*Plus command, and then runs a SQL script. It looks
like AOLserver was doing something extra, which Naviserver doesn't seem to do.
As a bit of background, when you run a SQL script in SQL*Plus, the script needs
to have an EXIT command on the last line, which tells SQL*Plus to exit when
finished. For some reason, in OpenACS, none of the provided SQL scripts have
this EXIT, but with AOLserver it was never an issue. It seemed to close the
channel after SQL*Plus was finished running.
With Naviserver, the pipe hangs while waiting on SQL*Plus to exit. The obvious
fix is to add the EXIT to the 1000s of SQL scripts included in OpenACS, but I'm
hoping there's a smarter solution (something along the lines of this, if
necessary http://serverfault.com/a/87038/9044 ).
Here's an example of what I'm talking about:
Create a file called hello.sql which contains the following line:
select 'brian says hi' from dual;
>From your command line, run it as follows:
sqlplus user/pass@SID @hello.sql
You will find that it doesn't exit the SQL*Plus session, unless you add an EXIT
to the end of hello.sql
Here is a version of the OpenACS code, that works on AOLserver (without the
EXIT command in the SQL script) but is hanging on Naviserver:
set file "c:/temp/hello.sql"
cd [file dirname $file]
set user_pass "user/pass@SID"
set fp [open "|[file join $::env(ORACLE_HOME) bin sqlplus] $user_pass @$file"
"r"]
set output ""
while { [gets $fp line] >= 0 } {
append output $line
}
close $fp
ns_log Notice $output
If hello.sql has an EXIT, you will see output similar to below. Otherwise, it
just waits, and you have to kill it.
SQL*Plus: Release 12.1.0.2.0 Production on Fri Feb 17 16:45:34 2017Copyright (c)
1982, 2014, Oracle. All rights reserved.Connected to:Oracle Database 11g Relea
se 11.2.0.3.0 - 64bit Production'BRIANSAYSHI'-----------------------------------
----brian says hiDisconnected from Oracle Database 11g Release 11.2.0.3.0 - 64bi
t Production
Any thoughts?
Brian
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel