Change standard output within a shell script

Change standard output within a shell script

Post by mandr.. » Sun, 24 Jan 1993 08:48:42



How do you change the definition of standard output within a csh script?
I have a shell script with a lot of "echo" commands and I want their
output to automatically go to a different file every day.  I don't want
to have to type a bunch of redirection symbols.

The shell script is running as a cron job.  I tried to redirect the file
as follows:

   00 2 * * 1-5 ~admin/bkup.test > ~admin/bkup_report/`date +%b_%d_%Y` 2>&1

But, when I did that, the output was put into a file with the name

   Fri Jan 22 02:00:00 CST 1993

Instead of

   Jan_22_1993

When I run the same command that I used in the cron at the normal ksh
prompt (since cron runs in ksh), it does create the filename I want.

Thanks in advance...

 
 
 

Change standard output within a shell script

Post by Eliot Wils » Fri, 29 Jan 1993 06:19:12



>How do you change the definition of standard output within a csh script?
>I have a shell script with a lot of "echo" commands and I want their
>output to automatically go to a different file every day.  I don't want
>to have to type a bunch of redirection symbols.

>The shell script is running as a cron job.  I tried to redirect the file
>as follows:

>   00 2 * * 1-5 ~admin/bkup.test > ~admin/bkup_report/`date +%b_%d_%Y` 2>&1

>But, when I did that, the output was put into a file with the name

>   Fri Jan 22 02:00:00 CST 1993

>Instead of

>   Jan_22_1993

>When I run the same command that I used in the cron at the normal ksh
>prompt (since cron runs in ksh), it does create the filename I want.

>Thanks in advance...

What I have done in the past using borne shell is this

exec > /my.output.filename

This cause stdout to change to this new file. Hope it helps.
-ELiot

--
Eliot Wilson      Univ. of Cincinnati      UG Computer Science
   A-in't         IBM Cincinnati AIX Open Systems Solution Team (a.k.a. limbo)
   I-t            Internet:                 VNET:  


 
 
 

1. shell script within shell script (general question)

When writing a shell script, quite often, I have to write bunch of
separate Awk/Python/etc scripts that are more than few lines.  And, of
course, I lose track of which script does what, especially if I have to
go back and forth with editor.

Is there a way to include those Awk/Python scripts inside of the main
shell script?  Essentially, I would like to write in the main shell
script,

    subfile test1 (/usr/bin/gawk -f) {
        ...
        /pattern/ {action}
        ...
    }

    subfile test2 (/usr/bin/python) {
        ...
        python stuffs
        ...
    }

instead of a file called "test1",

    #! /usr/bin/gawk -f
    ...
    /patthern/ {action}
    ...

and another file called "test2",

    #! /usr/bin/python
    ...
    python stuffs
    ...

Does anyone know which shell allows this?  If no such shell exists, then
how difficult would it be write a hook in the source?

        Yours truly,
--

Linux solution for data management and processing.

2. DOOM not playing sound

3. Changing directories within a bash shell script

4. Diamond Modem under Linux

5. Changing user within shell script

6. Alsa Sis7012 ALC650 S/PDIF

7. Automated password change from within shell script.

8. A badly missed feature in gcc

9. changing standard input in Korn Shell script

10. unix shell commands within ftp shell script

11. How to interact with a shell within a shell script

12. How to attach file to EMAIL MESSAGE within shell script(Korn shell)