In a message dated: Fri, 07 Jun 2002 12:46:41 EDT
Warren Mansur said:

>Does anyone know how to detect where the output is going from within a
>script?  That is, I want my script behave differently if I do:
>
>% script.sh
>
>or
>
>% script.sh > myfile
>
>Does anyone know how to do this in a shell script?

Ahm, I don't think you can, since the shell is sending to STDOUT in 
this case, and STDOUT has been redirected at *shell* level to be 
someplace other than STDOUT; in this case, a file.  The script has no 
knowledge of what's going on here.  It's simply dumping to STDOUT.

You're best bet is to have your output structured the way you want to 
see it, then redirect it.

Or, have your shell script take a command line option to specify an 
output file.  Test if this option is used, then format accordingly.

Hope that helps.
-- 

Seeya,
Paul
----
        It may look like I'm just sitting here doing nothing,
   but I'm really actively waiting for all my problems to go away.

         If you're not having fun, you're not doing it right!



*****************************************************************
To unsubscribe from this list, send mail to [EMAIL PROTECTED]
with the text 'unsubscribe gnhlug' in the message body.
*****************************************************************

Reply via email to