1830056 Members
1680 Online
109998 Solutions
New Discussion

>> doesn't work

 
SOLVED
Go to solution
Vlad_11
Frequent Advisor

>> doesn't work

#!/usr/bin/sh
set -x
...
LOGFILE=log
...
date > dateline
...
cat dateline >> $LOGFILE
...
cat temp3 >> $LOGFILE
...
echo "....DONE" >> $LOGFILE
...
Hi, I have s script that execute lines like above. The problem that dateline info never comes into logfile. It's not my script and I came from other platform, so start thinking what cab be wrong with it, maybe there is any kind of syncpoint or ">>" is not working as a concatinating with some conditions, or ...

Thanks
Vlad
beer or not beer
8 REPLIES 8
Fred Ruffet
Honored Contributor

Re: >> doesn't work

Could you post the whole script ? There must be external influence here, cause >> is known to work. Do you have both temp3 and "...DONE" in your $LOGFILE.

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
RAC_1
Honored Contributor
Solution

Re: >> doesn't work

Because you need

cat /full_pth/dateline >> $LOGFILE


Anil
There is no substitute to HARDWORK
Steve Steel
Honored Contributor

Re: >> doesn't work

Hi


Computers never do what you want them to do . Only what you ask them to do


Could you post the script and the output when run with set -x

Look at www.shelldorado.com for a good scripting source


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Pete Randall
Outstanding Contributor

Re: >> doesn't work

$date > dateline
$ LOGFILE=log
$ cat dateline >> $LOGFILE
$ cat log
Mon Nov 15 10:03:22 EST 2004

A quick test seems to work for me. Maybe if you post the whole script something else will show up but, as is, it should work.


Pete

Pete
A. Clay Stephenson
Acclaimed Contributor

Re: >> doesn't work

Why add the extra step of outputting to an intermediate file and then catting the intermediate file? Eliminate it altogether by simply:

date >> ${LOGFILE}


If it ain't broke, I can fix that.
Fred Ruffet
Honored Contributor

Re: >> doesn't work

Clay is right : You could suppress the step of putting date into this file.

If you want to store the starting date of your script, you can do it in a variable :
dateline=$(date)
echo $dateline >> $LOGFILE
it would suppress the risk of having two script using this file.

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Vlad_11
Frequent Advisor

Re: >> doesn't work

Hi, all
Thansk to everyone, for support.
The whole script is too big to post, and my posting reflected all problems.
There is a cd $WDIR at the very beginning and it was the problem, as it pointed to common root where 30 scripts were ran. THansk RAC !!!
Thansk all again.
I also will do date >> directly into log.


Best
Vlad
beer or not beer
Bill Hassell
Honored Contributor

Re: >> doesn't work

I would grep for the LOGFILE string in all the related scripts and see if there is a rogue > rather than >>. One simple character but the ">" erases an existing file and starts over.


Bill Hassell, sysadmin