On 19 Dec 2001, Kevin D. Clark wrote:

>
> 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...)

Sadly, the constraints that I am under won't allow the use of perl,
expect or other "layered" tools.

> > #!/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.

Thanks for the suggestion. I just tried it and sadly it has no noticable
effect.

> > 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.

In my opinion, no. The commands include scp, md5sum, tar, mkfs, mount,
umount,echo, read, grep, kill, rm, and so forth. I guess that maybe the
use of "echo -n" and "read" is the closest to that in the script.

- Marc


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

Reply via email to