Marc Evans <[EMAIL PROTECTED]> writes:

> Since I also have the constraint that this same script must work on common
> Linux platforms, I have to come up with an alternative to the script
> command. So I think, maybe this will work:
> 
> [ "$LOG" = '' ] && \
>   { export LOG=mylog.`date +%Y%m%d%H%M%S` ; exec bash -c "$0 $* 2>&1 | tee 
>/tmp/$LOG" ; }
> 
> Yeah, I loose the logging of input information, but it largely
> works.

Would you be willing to use something less portable if it also
preserved user input?  Like Expect or by utilizing a Perl module...

(damn, "script" is useless without that feature...)

> #!/bin/bash
> 
> [ "$LOG" = '' ] && \
>   { export LOG=mylog.`date +%Y%m%d%H%M%S` ; exec bash -c "$0 $* 2>&1 | tee 
>/tmp/$LOG" ; }

This looks reasonable.  I recall doing something like this once.

Out of curiosity, what happens if you do {something like} this instead:

[ "$LOG" = '' ] && \
  ( LOG=mylog.`date +%Y%m%d%H%M%S` ; export LOG ; "$0" "${@}" 2>&1 | tee /tmp/$LOG ; )

[ "$LOG" = '' ] && exit $?


Yes, this uses more sub-shells, but it might prod this into working.

> So, my question becomes, has anyone had to do anything similiar in their
> own scripts, and if so what mechanism did you use? Does anyone see
> anything obviously wrong in my approach and/or do you know of any issues
> that might cause the non-termination of the program when it is made more
> complex then the last example?

Are any of the <things> that you are eliding in your example doing
anything weird with the terminal?  Just wondering.

--kevin
-- 
Kevin D. Clark (CetaceanNetworks.com!kclark)  |
Cetacean Networks, Inc.                       |   Give me a decent UNIX
Portsmouth, N.H. (USA)                        |  and I can move the world
alumni.unh.edu!kdc (PGP Key Available)        |


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

Reply via email to