Writing script to log


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Writing script to log
# 1  
Old 09-17-2013
Writing script to log

Hi,
I have a shell script which contains
echo 'hello' >> $logfile
while executing my script i want the hello should be written in log file and also hello should be printed.

Thanks in Advance
# 2  
Old 09-17-2013
Code:
echo hello | tee -a logfile

the -a switch to tee appends to the file.

Andrew
# 3  
Old 09-17-2013
Printed to where? Try the tee command, and direct it to where you want your log printed (e.g./dev/tty).
# 4  
Old 09-19-2013
you can use :

Code:
exec > $logfile

at the top and anything within the script will go to your logfile.

Or give more info of what your looking for
# 5  
Old 09-19-2013
It'd easily be done outside the script with
Code:
./script | tee logfile

Otherwise, to print twice, you must print twice.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Writing the output of set -x into Log files

Hi Guys, I am using set -x in my script to track the flow of the script. But if i want to write the output of the set -x into a log file, how do i do it? Thanks, Ajay (3 Replies)
Discussion started by: Ajay Venkatesan
3 Replies

2. Shell Programming and Scripting

Need help in writing a script that do internal grep on a log file..and extract acct no's from it..

I need to write a script, which takes the input a log file and create output file with acct no's line by line from selected records with text like (in red) : 18:51:18 | 217863|Acct 0110855565|RC 17608| 16 Subs| 1596 UsgRecs| 2 Secs| 430 CPUms| prmis2:26213 <MoveUsage d aemon needs to run... (7 Replies)
Discussion started by: rkrish
7 Replies

3. Shell Programming and Scripting

Writing a UNIX script from LOG to provide return code.

Folks - Firstly, I do apologize that my first post here is a question. I am quite familiar with UNIX since our application is running on it. We are trying to automate a few things on our end and I am challenged with a task in hand that requires UNIX scripting. I am totally a newbie in UNIX... (4 Replies)
Discussion started by: sk72
4 Replies

4. Shell Programming and Scripting

How to check if a script is writing to a log

Hello, I have various scripts that writes to logs ( >> ) in different directories. I have create a script to automatically check different direcories for different errrors. However I do not want to remove logs if a script is still writing to a log. Is the log file opened for writing when the... (7 Replies)
Discussion started by: drbiloukos
7 Replies

5. Shell Programming and Scripting

Help writing a script check log not update.

:wall:Dear All.:p How to check log size every 10min. by script (not crontab) if log size not change with alert "Log not update" My Path :: /usr/home/logical/mono/log/tplink/ My Log :: mono11_tplink.log , mono12_tplink.log , etc I want oup put. EX. if log not update. . . . Fri Jan ... (1 Reply)
Discussion started by: ooilinlove
1 Replies

6. UNIX for Dummies Questions & Answers

Log File Writing and Reading

Hi all, I have the following shell script code which tries to sftp and writes the log into the log file. TestConnection () { echo 'Connection to ' $DESTUSERNAME@$DESTHOSTNAME $SETDEBUG if ]; then rm $SCRIPT ; fi touch $SCRIPT echo "cd" $REMOTEDIR >> $SCRIPT echo "quit" >>... (10 Replies)
Discussion started by: valluvan
10 Replies

7. UNIX for Advanced & Expert Users

writing the log file into syslog

Hi, we are trying to enable auditing for few oracle 9i database. and right now it writies into adump directory. As adump can be read/write by oracle user so could it be possible to write into syslog while oracle keeps writing to adump . thanks in advance. Pk (2 Replies)
Discussion started by: p4cldba
2 Replies

8. Shell Programming and Scripting

Writing to a log file incorrectly

I have this script: #!/bin/ksh ######### Environment Setup ######### PATH=/gers/nurev/menu/pub/sbin:/gers/nurev/menu/pub/bin:/gers/nurev/menu/pub/mac :/gers/nurev/menu/adm/sbin:/gers/nurev/menu/adm/bin:/gers/nurev/menu/adm/mac:/ge... (5 Replies)
Discussion started by: heprox
5 Replies

9. Shell Programming and Scripting

Which Process is writing this Log file!!

Hello , Well I have some /tmp files which are growing very quickly..Can anyone suggest me a way to find which process is logging into this file :confused: ? Thanks very much in Advance!! Mohammed (2 Replies)
Discussion started by: Mohammed
2 Replies

10. Shell Programming and Scripting

modifying the writing of a log...

Hi , i would submit the following way of writing into a log : i'm using Lotus Notes under AIX and a lotus system script is writing the all notes log this way : 11/04/2005 15:34:36 Router: Message 00496E70 transferred to XHUB003A/SRV/EDFGDF/FR for xxx@yyyyyy.com via Notes 11/04/2005... (2 Replies)
Discussion started by: Nicol
2 Replies
Login or Register to Ask a Question