Sponsored Content
Top Forums Shell Programming and Scripting Problem with here-document not seeing delimiter Post 303019400 by edstevens on Thursday 28th of June 2018 03:12:44 PM
Old 06-28-2018
I considered non-printing characters, but when I put vi into hex mode to investigate I found nothing amiss. Just EOL (x'0A') where they should be.
Code:
0000000: 2321 2f62 696e 2f73 680a 4f52 4145 4e56  #!/bin/sh.ORAENV
0000010: 5f41 534b 3d4e 4f0a 6563 686f 2022 2a2a  _ASK=NO.echo "**
0000020: 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a  ****************
0000030: 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a  ****************
0000040: 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a  ****************
0000050: 2a2a 2a22 0a65 6368 6f20 222a 2a20 2020  ***".echo "**
0000060: 2053 746f 7020 616c 6c20 6461 7461 6261   Stop all databa
0000070: 7365 7320 616e 6420 6c69 7374 656e 6572  ses and listener
0000080: 220a 6563 686f 2022 2a2a 2a2a 2a2a 2a2a  ".echo "********
0000090: 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a  ****************
00000a0: 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a  ****************
00000b0: 2a2a 2a2a 2a2a 2a2a 2a2a 2a2a 2a22 0a65  *************".e
00000c0: 6772 6570 202d 6920 275e 6872 397c 5e66  grep -i '^hr9|^f
00000d0: 7339 2720 2f65 7463 2f6f 7261 7461 6220  s9' /etc/oratab
00000e0: 7c5c 0a20 2020 6177 6b20 2d46 5c3a 2027  |\.   awk -F\: '
00000f0: 7b70 7269 6e74 2024 317d 277c 5c0a 7768  {print $1}'|\.wh
0000100: 696c 6520 7265 6164 204f 5241 434c 455f  ile read ORACLE_
0000110: 5349 440a 646f 0a20 2020 6563 686f 2070  SID.do.   echo p
0000120: 726f 6365 7373 696e 6720 244f 5241 434c  rocessing $ORACL
0000130: 455f 5349 440a 2020 2073 6f75 7263 6520  E_SID.   source
0000140: 6f72 6165 6e76 200a 2020 2073 716c 706c  oraenv .   sqlpl
0000150: 7573 202f 2061 7320 7379 7364 6261 203c  us / as sysdba <
0000160: 3c2d 454f 460a 2020 2020 2073 6875 7464  <-EOF.     shutd
0000170: 6f77 6e0a 454f 4620 2020 0a64 6f6e 650a  own.EOF   .done.
0000180: 6c73 6e72 6374 6c20 7374 6f70 0a         lsnrctl stop.

With the suggested hyphen, no joy:
Code:
oracle:$ cat stop_all.sh
#!/bin/sh
ORAENV_ASK=NO
echo "*****************************************************"
echo "**    Stop all databases and listener"
echo "*****************************************************"
egrep -i '^hr9|^fs9' /etc/oratab |\
   awk -F\: '{print $1}'|\
while read ORACLE_SID
do
   echo processing $ORACLE_SID
   source oraenv
   sqlplus / as sysdba <<EOF
     shutdown
EOF
done
lsnrctl stop

2018-06-28 14:10:51
oracle:$ ./stop_all.sh
*****************************************************
**    Stop all databases and listener
*****************************************************
./stop_all.sh: line 16: warning: here-document at line 12 delimited by end-of-file (wanted `EOF')
./stop_all.sh: line 17: syntax error: unexpected end of file

2018-06-28 14:10:55
oracle:$

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Problem Using Cut With A Space Delimiter

I am trying to extract 'postmaster' from the following string: PenaltyError:=554 5.7.1 Error, send your mail to postmaster@LOCALDOMAIN using the following command: cat /usr/share/assp/assp.cfg | grep ^PenaltyError:= | cut -d '@' -f1 | cut -f8 but it returns: PenaltyError:=554 5.7.1 Error,... (10 Replies)
Discussion started by: cleanden
10 Replies

2. Shell Programming and Scripting

Substring based on delimiter, finding last delimiter

Hi, I have a string like ABC.123.XYZ-A1-B2-P1-C4. I want to delimit the string based on "-" and then get result as only two strings. One with string till last hyphen and other with value after last hyphen... For this case, it would be something like first string as "ABC.123.XYZ-A1-B2-P1" and... (6 Replies)
Discussion started by: gupt_ash
6 Replies

3. Shell Programming and Scripting

Problem in extraction when space is a field delimiter

I have more than 1000 files to parse. Each file contains few lines (number of lines varies) followed by a header line having all column's name (SPOT, NAME etc) and then values for those columns. **Example File: sdgafh dfhaadfha sfgaf dhah jkthdj SPOT NAME GENE_NAME CH_MEAN CHDN_MED ... (11 Replies)
Discussion started by: AshwaniSharma09
11 Replies

4. Programming

perl - problem sending text with delimiter

Hello, i encountered this in perl but it might be command line related as well: i am sending text as an argument to echo command on remote computer. if the text has alphanumeric characters only, say 'hello world' all is well. if however text has metacharachters, e.g. 'hello | world' or even... (2 Replies)
Discussion started by: ole111
2 Replies

5. UNIX for Dummies Questions & Answers

Problem with Sudo inside a here document

Have a sudo statement inside of a here document. It prompts me for a password, but doesnt wait for me to enter my password. Is there a way I can use the command without sudo or anyway that I can enter the password correctly? Eg : while read remotehost do ssh -t $2@$remotehost ... (0 Replies)
Discussion started by: mnanavati
0 Replies

6. Shell Programming and Scripting

Here document inside a here document?

Can we use a here document inside a here document? Something like this ssh user@remotehost << REMOTE sudo vserver vsernamename enter << VSERVER perform actions on vserver. VSERVER REMOTE (6 Replies)
Discussion started by: mnanavati
6 Replies

7. Shell Programming and Scripting

ssh uses here-document problem

I try to ssh uses bash script in here-document like this. ssh root@$SERVER <<EOF if ; then service httpd start fi exit EOF But got an error below. maybe the if command causes the problem. Thanks for help. (2 Replies)
Discussion started by: muffle
2 Replies

8. Shell Programming and Scripting

Shell script to put delimiter for a no delimiter variable length text file

Hi, I have a No Delimiter variable length text file with following schema - Column Name Data length Firstname 5 Lastname 5 age 3 phoneno1 10 phoneno2 10 phoneno3 10 sample data - ... (16 Replies)
Discussion started by: Gaurav Martha
16 Replies

9. Shell Programming and Scripting

Perl Code to change file delimiter (passed as argument) to bar delimiter

Hi, Extremely new to Perl scripting, but need a quick fix without using TEXT::CSV I need to read in a file, pass any delimiter as an argument, and convert it to bar delimited on the output. In addition, enclose fields within double quotes in case of any embedded delimiters. Any help would... (2 Replies)
Discussion started by: JPB1977
2 Replies

10. Shell Programming and Scripting

Problem in using cut command with pipe as a delimiter while using in a script

There is a text file in my project named as "mom.txt" in which i want to have contents like.................. LSCRM(Application Name): 1: This is my first application. 2: Today we did shell scripting automation for this app. 3: It was really a good fun in doing so. 4: Really good.| (Here i... (7 Replies)
Discussion started by: Abhijeet Anand
7 Replies
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.10 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 11:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy