LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-02-2008, 10:19 AM   #1
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 504

Rep: Reputation: 31
Create log file against a script


Dear friends ,

Is it possible to create a "logfile" against a script in Linux platform ?

Suppose I have a script like following :

=============================================
Date1=`date +%d%b%Y`
Date2=`date +%d%b%Y`.`date +%I`.`date +%M%p`
cd /test
tar -cvf test1_$Date2.tar test1
tar -cvf test2_$Date2.tar test2
ftp -i -v -n 192.168.10.1 <<END_FTP
user oracle oracle
binary
cd /tmp
mput test1_$Date2.tar
mput test2_$Date2.tar
bye
============================================

Now if I want to create a logfile against this script , then is it possible ? plz inform me .....
 
Old 01-02-2008, 11:54 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 67
What do you mean "against this script"? Do you mean that you want to keep a record of the script output in a file?

If so, you can do it in several ways:
  1. Re-direct the output like this:
    Code:
    script_filename > my.log
    The (possible) disadvantage of this is that you won't see the normal output in the terminal, which you might want to see.
  2. Use tee:
    Code:
    script_filename | tee my.log
    This way you will see the output in the terminal and get the log file.
  3. use the script command:
    Code:
    script my.log
    script_filename
    (press control-D to end transcript)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create log file from script fotoguy Programming 12 03-27-2012 06:39 AM
Create a script to display file name, Inode, and size of any file. Has to be a script JaxsunApex Linux - Newbie 7 01-29-2007 08:15 PM
Create a shell Script that log in as root mashed Linux - Newbie 1 04-08-2006 04:13 AM
need to create log file sanjay2004 Linux - Newbie 6 02-27-2006 11:11 AM
Script to create a log file satimis Programming 15 01-16-2006 06:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration