Weird character in between echo function


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Weird character in between echo function
# 1  
Old 11-05-2008
Weird character in between echo function

Hi All,

Appreciate if anyone can help. I've a script where it does echo function like this

while [ $w -lt $CNT ]
do
FILE_ARG="cu0${w}_${FILE}_${DT}.av"

ORACLE_ERROR=`grep "ORA-" ${FILE_ARG}`
if [[ ${ORACLE_ERROR} != "" ]]; then
Func_Log_Writer "Fail! ${FILE_ARG}\n"
Func_Log_Writer "Error message: ${ORACLE_ERROR}\n"
Func_Exit 1
fi

w=`expr $w + 1`

if [ $w -eq $CNT ]; then
echo "0"
return 0
fi
done

However, when the message print to screen, it return in one line though i've include \n.

Output from script:

./DM_val_procedure_test.ksh[286]: [2008-11-05 16:35:35] Error message: ORA-12154: TNS:could not resolve service name^J[2008-11-05 16:35:35] Return code of validation is 1^J[2008-11-05 16:35:36] Terminated application!^J1: Syntax error
# 2  
Old 11-05-2008
The ^J is the \n character you put in the echo statement.
You will have to change the way you write to stdout.

Where is the code that actually does the echo? I gather it is a function called Func_Log_Writer - please post that.
# 3  
Old 11-05-2008
Try this contruct to process each error message in turn:

grep "ORA-" ${FILE_ARG} | while read ORACLE_ERROR
do
# Process each error message in ORACLE_ERROR
done
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using echo to print arguments inside a function

I am using echo in bash. Have created a function prargv which takes a number of arguments. Example: prargv "-e" "--examples" Inside prargv, I want to print all the arguments using echo echo "$@" This returns --examples rather than -e --examples" This problem can be fixed... (3 Replies)
Discussion started by: kristinu
3 Replies

2. Shell Programming and Scripting

Function to add escape character before specified character

Hi , I am looking for a function which will do the following. 1. I have a variable which will hold few special chracter like SPECIAL_CHARS="& ;"2. I have an escape character. ESCAPE_CHAR="\"3. Now when I passed some string in the function it will return the same string but now it will... (8 Replies)
Discussion started by: Anupam_Halder
8 Replies

3. Shell Programming and Scripting

Echo to file using SH without adding newline character

Hello! I am able to do this in bash, using: echo -ne HELLO > file.txt and then, 'HELLO' is written into file.txt without the newline character to be added in the end of the file. How is this possible to be done using sh instead of bash? If I try something similar is SH, then inside... (3 Replies)
Discussion started by: hakermania
3 Replies

4. Shell Programming and Scripting

please explain why this ksh echo deletes character

Please explain why this works. Am unable to find another definition for the '%', which would explain this behaviour: spaceLeft=`df -h /myPartition | tail -1` # output looks like: /dev/sda5 10G 1.2G 12G 29% / set -- $space #this deletes the trailing '%' sign, which is... (6 Replies)
Discussion started by: frododot
6 Replies

5. Programming

A weird problem with POSIX function

Hi all, Sorry for the title because I didn't find a proper name for it. My question is about POSIX functions, such as timer_create(), mq_open() and pthread_create(). void test_queue() { struct mq_attr attr; attr.mq_maxmsg = 10; attr.mq_msgsize = 64; mq_unlink("/my_test_queue");... (6 Replies)
Discussion started by: bus147
6 Replies

6. Shell Programming and Scripting

In bash getting weird output from function ?

My script- result="" times() { echo "inside the times function" result=8 echo "Inside function $result" return $result } result=$(times) echo "the value is "$? echo "the value of result $result" when I run I get this, why the value still remain 0. $ ./func the value is 0 the value... (5 Replies)
Discussion started by: boy18nj
5 Replies

7. Shell Programming and Scripting

Cleanup Weird character in Unix

Hi, I have a pipe delimited file and I am running into an issue where a field is having some weird character and I am not able to clean it up. It is 2nd field and the weird character is M- . See below. cat -v test.dat 02169| M- PATRICKM- MCALEER |Y 01318| M- LARRYM- PETERSON |Y 30319|... (5 Replies)
Discussion started by: msalam65
5 Replies

8. UNIX for Dummies Questions & Answers

echo without newline character

hi, I have a for loop where in I write some file name to another file. I want to write all the filenames to another without any newlines. how can i avoid getting new lines with echo? Thanks, Srilaxmi (2 Replies)
Discussion started by: srilaxmi
2 Replies

9. Shell Programming and Scripting

Reading password and echo * character

Hi, First of all i am using solaris 10. I want to write a script that ask user to enter password and read the character input from keyboard. The ask to re-enter the password and then if they are match it will accept. But my problem is I want to echo a '*' character instead of the character I... (4 Replies)
Discussion started by: alanpachuau
4 Replies

10. Shell Programming and Scripting

weird echo output?

#!/bin/bash INPUT=$1 if then INPUT=0$1 TRACKNUMBER=$INPUT fi TRACKNUMBER=$INPUT echo "Track Number:" $TRACKNUMBER if then echo "File Does Not Exist!: split-track"${TRACKNUMBER}".wav" exit 0 fi CUEFILE="$2" (6 Replies)
Discussion started by: TinCanFury
6 Replies
Login or Register to Ask a Question