I can resolve this problem, but I don't understand why it happens.
My task is: (in ksh)
- 1st step: Query a number from a DB with sqlplus,
- 2nd step: Format some text for a mail,
- 3rd step: send a mail with these.
This is a part of my code:
psnr() {
sqlplus -s USR/PASS@PROD << EOS
SET PAGESIZE 0
SET COLSEP ";"
SET FEEDBACK OFF
SET TRIMOUT ON
SET TRIMSPOOL ON
select max_number-last_number from postalslip
where state = 'OPEN'
/
exit
/
EOS
}
I got a number, 1234567, when I call this function.
PSNR=$(psnr)
I write a word for a mail:
echo "Today's result is: $PSNR" > $MAILTMP
if I want to use this variable MAILTMP I must use tr -d '\040\011' what I found here, in stackexchange, 'cause the result without tr will be this:
od -c mailtmp.17872.txt
0000000 T o d a y ' s r e s u l t i
0000020 s : \t 1 2 3 4 5
0000040 6 7 \n
0000043
That tab '\t' is what I don't understand: where does it come from, from sqlplus? Possibly DB specificity? (I checked in TOAD, both coloumns are number(18). Maybe the function in ksh have some special features?