Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirecting STDIN, STDOUT, STDERR to file via tee

Status
Not open for further replies.

sapatos

Programmer
Jan 20, 2006
57
AU
Hi,

I'm scripting a generic login script to oracle via sqlplus. I am having problems getting output from stdin in sqlplus but everything else is logged.

sqlplus username/password@instance | tee logfile

logfile contains all database output but nothing I typed into the command line whilst in the application. I guess that stdin is not being captured by the tee. I considered redirecting stdin to stdout 0>&1 for example but it doesn't like that much.

Any ideas?
 
Have you tried the Solaris command "script"
script [ -a ] [ filename ]
script - make record of a terminal session, see "man
 
thanks for the pointers. set echo on doesn't work as far as I can tell.

sqlplus connectstring | tee -a file

set echo on
select sysdate from dual;
exit

still shows nothign in the log file
 
and this ?
sqlplus connectstring 2>&1 | tee -a file

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
spool will only spool sqlplus output, I need to log everything that is typed as well. So far managed this only with prepared sql found in the FAQ at the beginning of this thread.

I tried PHV's suggestion and got:

sqlplus -s memcnfprd1/ircnfpp@ircnfpp2 2>&1 | tee -a logfilematt
Ambiguous output redirect.
 
Did you try 'spool', as suggested by marrow, together with 'set echo on' ?
 
(sqlplus -s memcnfprd1/ircnfpp@ircnfpp2 2>&1) | tee -a logfilematt

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I'm surprised "spool" is not displaying commands entered. I have just tested it and it shows my input "show parameter" & quit
tail -10 log
SQL> show parameter utl

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
utl_file_dir string ../FLATFILE

SQL> quit
 
MARROW:

weird, i'm getting:

tail logfilematt
SQL> SQL>
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
utl_file_dir string /tmp
SQL> Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production

HOINZ:

set echo on
spool logfilematt

does not work. I only get the output.
 
strange ....
For me, 'set echo on/off' makes the difference, whether or not I get my input in the spool file ...
 
Hello Sapatos, I would suggest you query on the Oracle9 forum as to why spool not showing input commands. There must be a parameter that's stopping the display. They will probably tell you why...
 
ok i'll check it out. Tnx guys. a lot of useful points there for me
 
Follow PHV's suggestion exactly. I.e., omit the -s (silent) option with sqlplus.

Cheers,
ND [smile]

[small]bigoldbulldog AT hotmail[/small]
 
Tried it earlier and get the following:

(sqlplus memcnfprd1/ircnfpp@ircnfpp2 2>&1) | tee -a ogfilematt
cat logfilematt

and nothing. Comes straight back to the command line.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top