Echo cannot redirect first or second output to logfile


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Echo cannot redirect first or second output to logfile
# 1  
Old 03-31-2014
Echo cannot redirect first or second output to logfile

I created a script to do some work. I want to use "echo" to redirect "date" to log file. echo works to screen. But cannot redirect first or second "echo" output to logfile. Please help. My code looks like:
Code:
STARTTIME=`date +%m-%d-%Y`
LOGFILE=/directory/logfile.log
echo "Start time:" $STARTTIME
echo "--------------------" > $LOGFILE
echo "Stert time:" $STARTTIME >> $LOGFILE
echo "Delete file" 
echo "Delete file" >> $LOGFILE
....
....
ENDTIME=`date +%m-%d-%Y`
echo "End time:" $ENDTIME
echo "End time:" $ENDTIME >> $LOGFILE

the script runs ok. but starttime and delete file output cannot be directed to logfile. All other echo output can be output on screen and be redirected to logfile. I cannot figure out why this happen. I searched online and cannot find good answer. Please adsvise and thanks a lot.
# 2  
Old 03-31-2014
What's the ownership and permissions on logfile.log ?
# 3  
Old 03-31-2014
I log in as Oracle super user. The file permission is -rw-r--r--
# 4  
Old 03-31-2014
And who owns it?
# 5  
Old 03-31-2014
The Oracle super user that I log in with
# 6  
Old 03-31-2014
Did you copy-paste the script, or rewrite a little mockup for here? Nothing appears wrong, but if you didn't copy-paste the actual script, there could easily be little things lost in translation. Any problem with the LOGFILE= assignment for example would stop it from working.
# 7  
Old 03-31-2014
Yes, the original script was created on my laptop. The upload to a web file repository. Then I log into another Virtual machine. Download script to this virtual machine. Then I used WinSCP copy the script to Solaris Server. After that, I used vi to edit the file and added log file and echo code to redirect output to logfile. Does this affect script work? Any other suggestion? Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh and Oracle stored procedure output in logfile

Friends, I pass some runtime arguments (date, number) through ksh script to Oracle procedure, use input value and pass it on to procedure. Oracle procedure gets input value, run query and logs everything in the logfile. I'm facing with couple of challenges 1. Even though I pass all... (5 Replies)
Discussion started by: homer4all
5 Replies

2. UNIX for Dummies Questions & Answers

Changes to write output to logfile and console

Friends, Below is the script which writes output to LOGFILE, however I want the entire log written to LOGFILE and also console. Please suggest me the changes I need to do here. #!/bin/ksh x=${0##*/} LOGFILE="x.log" echo "CAUTION : Files once deleted cannot be restored" printf 'Would... (8 Replies)
Discussion started by: fop4658
8 Replies

3. Shell Programming and Scripting

Redirect script output to a file and mail the output

Hi Guys, I want to redirect the output of 3 scripts to a file and then mail the output of those three scripts. I used below but it is not working: OFILE=/home/home1/report1 echo "report1 details" > $OFILE =/home/home1/1.sh > $OFILE echo... (7 Replies)
Discussion started by: Vivekit82
7 Replies

4. UNIX for Dummies Questions & Answers

Redirect output of echo to a file

Hi , I am trying to redirect output of echo to a file.So i wrote a function named printline.Here is my sample script myscript.sh function printline() { echo "$1" >> myfile.log } usage() { printLine "********************USAGE*************************" printLine "Script takes... (12 Replies)
Discussion started by: ASC
12 Replies

5. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

6. Shell Programming and Scripting

redirect stdout echo command in condition A run in condition B

hi, I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command Here are my simple script After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
Discussion started by: jao_madn
3 Replies

7. Shell Programming and Scripting

Redirect an "echo" to log and screen?

Hi folks. Within a script, i am trying to redirect the output of my commands to both log file and onscreen... Here is the section, where i write to the logfile. But i'd like to send the "echo "Creating LUN $2$COUNTER..." to screen as well... Can that be done? Thanks. { subtitle... (2 Replies)
Discussion started by: Stephan
2 Replies

8. Shell Programming and Scripting

how to create a logfile to track the below script output

Hi Dudes, Can you please suggest me how to create a logfile to track the below script output ? Thanks #!/bin/ksh # backup the "std" I/P file descriptor exec 5<&0 #echo "Proceed ?" while read config_line; do # backup the I/P file descriptor of "while" block exec 6<&0 # restore the... (2 Replies)
Discussion started by: shirdi
2 Replies

9. Shell Programming and Scripting

Parse Logfile output variable

<SUMMARY filecount_excluded="0" dirbytes_sent="3367893" dirbytes_hashcache="13275664" ..and so on..> <session numthreads="1" type="avtarbackup" ndispatchers="1" ..and so on..><host numprocs="4" speed="900" osuser="root" name="ashsux01" memory="24545" /><build time="11:04:53" msgversion="13-10" ... (11 Replies)
Discussion started by: Ikon
11 Replies

10. Shell Programming and Scripting

Redirect output

Hi all, I have a script which call a java program, the logging (to log file) in the program is done using log4j. However, as a safety measure, i still choose to direct standard error to another log file as follow /usr/bin/java -classpath ${classpath} -Xmx128m TestingProgram 2>>... (1 Reply)
Discussion started by: mpang_
1 Replies
Login or Register to Ask a Question