Have script redirect output?

Have script redirect output?

Post by kk_.. » Wed, 08 Mar 2006 21:26:57



Hi.  I am using a Bourne script like this:

myscript.sh >& myoutput.out

Instead of doing this, is there a command I can put inside my script to
cause it to redirect output in this way?

Thanks!

Ken

 
 
 

Have script redirect output?

Post by Stephane Chazela » Wed, 08 Mar 2006 21:31:49



Quote:> Hi.  I am using a Bourne script like this:

> myscript.sh >& myoutput.out

> Instead of doing this, is there a command I can put inside my script to
> cause it to redirect output in this way?

[...]

#! /bin/sh -
exec > myoutput.out 2>&1
# the remaining of your script goes here

or

#! /bin/sh -
{
  # your script goes here

Quote:} > myoutput.out 2>&1

Note that if myoutput.out can't be open for writing, the script
will stop at once and not do anything (which is probably what
you want).

--
Stephane

 
 
 

1. How to redirect some Perl script output to a file?

Hi all, hope this is an OK spot to post this question (redirections welcome).

I am using someone's Perl script to do some number crunching. Rather than
spend all day staring at the output flying by hoping to catch any errors
I'd like to let it run overnight if I could put all that stuff written to
screen in a file instead, which would be much easier to inspect to see
where things bomb if they do (and they probably will at first). The
problem is the script asks a couple questions first, to which you have to
enter parameters (yes, and 84).

Is there a simple shell command or trick that will let me run the script
and redirect everything written by the print statements to a file, after
I've answered the two questions?

I'm told I'm using the TCSH or tcshell on SGI machines. Normally I type
the name of the script:

      doPreprocess

answer the two questions and then stuff whizzes by in the window for hours.

Thanks most sincerely for any help,
Jim

2. XFree83-3.3 worked, but 3.3.1 doesn't with Trident-9385.

3. Redirect a shell script's output??

4. Too much for grep

5. Redirecting shell script output to screen

6. KSH: max # file descriptors for exec ???

7. script output redirected to tty.....what's up ?

8. Lock out users

9. ksh script redirecting ALL output tip

10. Redirecting program output to script input

11. output redirect from within script - how to?

12. How to redirect output from a SMF service (converted from run control script) in Solaris 10?

13. about error output redirect in ksh script