capturing log


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting capturing log
# 1  
Old 05-15-2006
capturing log

Hi
below is my script which copies test file to each directory in the file and checks if the permissions are ok, but I am not able to capture the log of the output.
here is the script
Code:
#! /usr/bin/sh
set -x
cd /dir/of/files
while read line
do
cp test.txt $line
rm  $line/test.txt
done < /dir/list/of/dir/dir_test.txt >> Directory_test.log
echo "DONE"

the file dir_test.txt has all directories listed, I am testing copy permissions and there are more that 200 directories where we have to check for ermission issues. All I want to do is capture the log file.

I am not able to capture it this way...any ideas...? I need to capture log into Directory_test.log

Thanks,
# 2  
Old 05-16-2006
Hi, you can use nohup.
Ex.
Code:
nohup yourscript &

That command generates a file (nohup.out) with the all output.

Cheers.

Last edited by Klashxx; 05-16-2006 at 04:05 AM..
# 3  
Old 05-16-2006
Try this :

Code:
#! /usr/bin/sh
exec > Directory_test.log 2>&1
set -x
cd /dir/of/files
while read line
do
cp test.txt $line
rm  $line/test.txt
done < /dir/list/of/dir/dir_test.txt 
echo "DONE"

# 4  
Old 05-16-2006
It worked, thanks a lot.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Capturing the keystroke

i have the below script: #!/bin/bash echo "enter a" read a echo "enter b" read b let c=a+b echo $c at any point of time between entering the value for a and b,if user presses ctrl+a key combination, then it should start from the beginning(the script should be restarted). it should... (4 Replies)
Discussion started by: pandeesh
4 Replies

2. Shell Programming and Scripting

Capturing errors messages into log file

Can we capture and write all the error messages which were being displayed on the command prompt screen during execution of a program into a log file? If yes, can anyone please let me know on how to do it? I am using ksh and working on AIX server. Thank you in advance. (4 Replies)
Discussion started by: vpv0002
4 Replies

3. Red Hat

Help for capturing a URL from a line from large log file

Can someone please help me how do I find a URL from lines of log file and write all the output to a new file? For e.g - Log file has similar entries, 39.155.67.5 - - "GET /abc/login?service=http://161.120.36.39/CORPHR/TMA2007/default.asp HTTP/1.1" 401 3218 54.155.63.9 - - "GET... (2 Replies)
Discussion started by: rockf1bull
2 Replies

4. Shell Programming and Scripting

Capturing script output and input to log

Hi Is there a way that I can capture a shell script (both output and input) to a log file where I can analyze it? Thanks (6 Replies)
Discussion started by: nimo
6 Replies

5. Shell Programming and Scripting

Capturing IP address

I'm trying my first shell script. I would like my computer to launch an application if I'm on my work network, or mount my shared files if I'm on my home network. Here's how I'm trying to do it... #!/bin/bash CURRENT_IP=ipconfig getifaddr en1 HOME=192.168.1.6 WORK=192.168.0.123 if ; then... (2 Replies)
Discussion started by: bcamp1973
2 Replies

6. Shell Programming and Scripting

Capturing log of a shell script

Hi, I have a script which does multiple tasks in sequence. When i execute the script, it runs and displays lot of messages for each of the steps on the console. Is there any way I can capture those messages and store it for audit purposes ? Best Regards, bornon2303 (2 Replies)
Discussion started by: bornon2303
2 Replies

7. UNIX for Dummies Questions & Answers

Capturing FTP log

I am trying to do the FTP using .netrc.In my .netrc file in $HOME dir i am placing the machine ip,user name and pwd.Then i am creating dynamically a file which contains the ftp commands. My script is like below: __________________________________ export REMOTE_DIR= <some path> export... (4 Replies)
Discussion started by: dr46014
4 Replies

8. Shell Programming and Scripting

Any suggestion on Capturing SFTP error in log ???

Hello All, I have searched the thread for capturing and got some suggestion but that is not working for me. I am trying to sftp to a window server from unix server and getting file there with out any issue .But i wan't to capture the error --in case a file is not exist in remote. Example :... (1 Reply)
Discussion started by: jambesh
1 Replies

9. Shell Programming and Scripting

Capturing value into variable

Hi, I am new to shell scripting, I am trying to write a shell script, which will automate the process of mailing the invoices at the end of the day. For major part I am using Oracle database function. The problem is I want to capture the value returned by the Oracle function into the script... (2 Replies)
Discussion started by: prasad01
2 Replies

10. Shell Programming and Scripting

capturing process id

I am newbie to unix shells world. I am trying to capture a background process id into a file so that it can be killed later. this process is basically a java program running in background as: java TestApp & this returning process id immediately. So how can i redirect that pid into a file.... (1 Reply)
Discussion started by: bvreddy
1 Replies
Login or Register to Ask a Question