Find the answer to your Linux question:
Results 1 to 4 of 4
Hi to all, i have a simple question: i redirect with a Code: exec &>filename.log all the script output: is there a trick to copy itself all the script without ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2005
    Posts
    6

    Copying a script without calling itself name


    Hi to all,
    i have a simple question:
    i redirect with a
    Code:
    exec &>filename.log
    all the script output: is there a trick to copy itself all the script without "calling its name" (so is script_name indipendent) at the begin of the log?
    and after that exec command.. wich command must i use for return the output to the "showed" teminal? (i have looked in many documents without find a solution..)
    eg:
    Code:
    echo "start" 
    exec &>$ARCHIVE/filelog.log
    echo "-------"
    echo "i want this on the log" 
    echo "i'd like this echo (at the end of the script out of the log"
    i'd like a log like this
    Code:
    echo "start" 
    exec &>$ARCHIVE/filelog.log
    echo "-------"
    echo "i want this on the log"
    echo "i'd like this echo (at the end of the script out of the log"
    -------
    i want this on the log
    i know that this is a very simple question.. but i need help
    and i hope that these probs are clear

  2. #2
    Linux Newbie
    Join Date
    Oct 2004
    Posts
    158
    Code:
    exec &>$ARCHIVE/filelog.log 
    cat $0       # this will create a copy of the script in the log file
    I'm really not at all sure what you want. This my take on it.

  3. #3
    Just Joined!
    Join Date
    Sep 2005
    Posts
    6
    really thx
    cat "$0"
    works perfectl!
    (i will give a look for this $0 ..)

    any idea to return to the terminal after the exec &>namefile.log ?
    (i' have not found a solution for this simplex question..)

  4. #4
    Linux Engineer
    Join Date
    Nov 2004
    Location
    home
    Posts
    796
    You can run you command in the background by putting & at the end of it. This will allow you to use the terminal still. If you want to see how the log is going, the tee command might be useful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •