CHR(10) does not work from shell script [message #617138] |
Wed, 25 June 2014 07:45 |
|
sinpeak
Messages: 59 Registered: January 2011 Location: india
|
Member |
|
|
Hi,
Here is a snippet from my ksh script :
MV_CREATION=`sqlplus -S $DATABASE <<-_END
SET SERVEROUTPUT ON;
SET PAGES 0;
SET LINESIZE 255;
SET FEEDBACK OFF;
SET NEWLINE ON;
EXEC DBMS_OUTPUT.PUT_LINE('INFORM----FCFmv:'||'PLSQLLINE' ||':'|| TO_CHAR(SYSDATE,'DD/MM/YY HH24:MI:SS') || ' > Dropping public synonym.'||CHR(10));
EXEC DBMS_OUTPUT.NEW_LINE;
Both CHR(10) and DBMS_OUTPUT.NEW_LINE do not seem to work.
The output does not have a new line.
Tried CHR(13) as well. Does not work.
Any advise ?
Thanks.
|
|
|
|
|
Re: CHR(10) does not work from shell script [message #617154 is a reply to message #617138] |
Wed, 25 June 2014 09:37 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
I suggest you have a log file to capture the details. Else you might just lose the output details and also do the manual activity of copy pasting from what you see on the screen.
I bet neither korn shell nor Oracle is the culprit. Try it once again with a log file and copy paste the log file contents alongwith your script. That would show a crystal clear picture.
|
|
|
|
|
|
|
|
Re: CHR(10) does not work from shell script [message #617164 is a reply to message #617163] |
Wed, 25 June 2014 11:24 |
|
BlackSwan
Messages: 26766 Registered: January 2009 Location: SoCal
|
Senior Member |
|
|
[oracle@localhost ~]$ sqlplus user1/user1 @nl.sql
SQL*Plus: Release 11.2.0.2.0 Production on Wed Jun 25 09:20:10 2014
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> SPOOL NL.LOG
SQL> BEGIN
2 DBMS_OUTPUT.PUT_LINE('LINE1');
3 DBMS_OUTPUT.NEW_LINE;
4 DBMS_OUTPUT.PUT_LINE('LINE2');
5 DBMS_OUTPUT.NEW_LINE;
6 DBMS_OUTPUT.NEW_LINE;
7 DBMS_OUTPUT.PUT_LINE('LINE3');
8 DBMS_OUTPUT.NEW_LINE;
9 DBMS_OUTPUT.NEW_LINE;
10 DBMS_OUTPUT.NEW_LINE;
11 DBMS_OUTPUT.PUT_LINE('LINE4');
12 DBMS_OUTPUT.PUT_LINE(CHR(10)||CHR(10));
13 DBMS_OUTPUT.PUT_LINE('LINE5');
14 DBMS_OUTPUT.PUT_LINE(CHR(13)||CHR(13));
15 DBMS_OUTPUT.PUT_LINE('LINE6');
16 END;
17 /
LINE1
LINE2
LINE3
LINE4
LINE5
LINE6
SQL> SPOOL OFF
SQL> EXIT
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost ~]$ od -c NL.LOG
0000000 S Q L > B E G I N \n 2
0000020 D B M S _ O U T P U T . P U T _
0000040 L I N E ( ' L I N E 1 ' ) ; \n
0000060 3 D B M S _ O U T P U T .
0000100 N E W _ L I N E ; \n 4 D
0000120 B M S _ O U T P U T . P U T _ L
0000140 I N E ( ' L I N E 2 ' ) ; \n
0000160 5 D B M S _ O U T P U T . N
0000200 E W _ L I N E ; \n 6 D B
0000220 M S _ O U T P U T . N E W _ L I
0000240 N E ; \n 7 D B M S _ O U
0000260 T P U T . P U T _ L I N E ( ' L
0000300 I N E 3 ' ) ; \n 8 D B M
0000320 S _ O U T P U T . N E W _ L I N
0000340 E ; \n 9 D B M S _ O U T
0000360 P U T . N E W _ L I N E ; \n 1
0000400 0 D B M S _ O U T P U T . N
0000420 E W _ L I N E ; \n 1 1 D B
0000440 M S _ O U T P U T . P U T _ L I
0000460 N E ( ' L I N E 4 ' ) ; \n 1 2
0000500 D B M S _ O U T P U T . P U
0000520 T _ L I N E ( C H R ( 1 0 ) | |
0000540 C H R ( 1 0 ) ) ; \n 1 3 D
0000560 B M S _ O U T P U T . P U T _ L
0000600 I N E ( ' L I N E 5 ' ) ; \n 1
0000620 4 D B M S _ O U T P U T . P
0000640 U T _ L I N E ( C H R ( 1 3 ) |
0000660 | C H R ( 1 3 ) ) ; \n 1 5
0000700 D B M S _ O U T P U T . P U T _
0000720 L I N E ( ' L I N E 6 ' ) ; \n
0000740 1 6 E N D ; \n 1 7 / \n
0000760 L I N E 1
0001000
*
0001340 \n
0001360 L I N E 2
0001400
*
0001740 \n
0001760 L I N E 3
0002000
*
0002340 \n
0002360 L I N E 4
0002400
*
0002740 \n
0002760 \n \n
0003000
*
0003340 \n
0003360 L I N E 5
0003400
*
0003740 \n
0003760 \r \r
0004000
*
0004340 \n
0004360 L I N E 6
0004400
*
0004740 \n
0004760 S Q L > S P O O L O F F \n
0004777
[oracle@localhost ~]$ cat nl.sql
SET SERVEROUTPUT ON
SET PAGES 0
SET LINESIZE 255
SET FEEDBACK OFF
SET TERM ON ECHO ON
SPOOL NL.LOG
BEGIN
DBMS_OUTPUT.PUT_LINE('LINE1');
DBMS_OUTPUT.NEW_LINE;
DBMS_OUTPUT.PUT_LINE('LINE2');
DBMS_OUTPUT.NEW_LINE;
DBMS_OUTPUT.NEW_LINE;
DBMS_OUTPUT.PUT_LINE('LINE3');
DBMS_OUTPUT.NEW_LINE;
DBMS_OUTPUT.NEW_LINE;
DBMS_OUTPUT.NEW_LINE;
DBMS_OUTPUT.PUT_LINE('LINE4');
DBMS_OUTPUT.PUT_LINE(CHR(10)||CHR(10));
DBMS_OUTPUT.PUT_LINE('LINE5');
DBMS_OUTPUT.PUT_LINE(CHR(13)||CHR(13));
DBMS_OUTPUT.PUT_LINE('LINE6');
END;
/
SPOOL OFF
EXIT
[oracle@localhost ~]$
|
|
|