tobold.org

correct • elegant • free

△ comp.unix.shell △

◅ Those Damn Users' Caches Won't Go Away ...

Better cron output handling? ▻

Help, I want to do baaaad things :-)

In article <8b93t0$pi9$1@commsun.its.csiro.au>,
Anthony Wyatt <Anthony..Wyatt@@its..csiro..au.bogus> wrote:
>OK now a little explanation, the ls /fsdf is to get $? set to a non-zero
>value, but I have no idea how to do this any other way, I also tried until
>instead of while but it seemed to skip the entire block.

What's the point of the loop, anyway?

If there's a process on the other machine creating the file, and you
want to copy it as soon as it exists, a better way would be to get the
machine that creates it to copy it.

(Incidentally, at least some versions of `scp' don't actually return
non-zero if they failed to copy the file!  They should, of course, be
taken out and shot...)

>                                                          Next it sees if
>it's running from a terminal if it is it echos what it's doing else it's
>quiet.  What I'd like to do is change the ascii bit of the process ID to say
>what it's doing if it's not run from a shell.  Can this be done?  Should I
>just log it instead?

Yeuch.  First of all, you should avoid modifying your behaviour on the
basis of `test -t' unless you really, really, have to.  (The canonical
bad example is Berzerkeleyized `ls'.)  Second, changing the process name
is grody, not portable, and not---so far as I know---doable in a shell
script.  (Those wacky West Coast guys provide the canonical bad example
here, too: sendmail.)

Build on Unix's strengths---it's much more fun in the long run.  If at
all possible, be silent unless there are errors.  If your process is
long running, or you're not (yet!) happy with successful silence, write
your progress reports to standard output, and let the script's invoker
deal with them.  Then they can be easily ignored (`> /dev/null'),
selected (`| grep -v status'), logged (`>> /var/log/foo', or perhaps
something like `| multilog /var/log/foo'), and manipulated with the
whole Unix toolbox.

(Whew!  That got a bit theological... No offence intended to followers
of other religions... :-)

Tim.
--
Tim Goodwin   | "If you don't know what closures are, you probably don't
Leicester, UK | want to know what closures are." -- Larry Wall

Original headers:

From: tjg@star.le.ac.uk (Tim Goodwin)
Newsgroups: comp.unix.shell
Subject: Re: Help, I want to do baaaad things :-)
Date: 24 Mar 2000 10:35:25 -0000
Message-ID: <8bfge3$mj6$1@ltpcg.star.le.ac.uk>
References: <8b93t0$pi9$1@commsun.its.csiro.au>

△ comp.unix.shell △

◅ Those Damn Users' Caches Won't Go Away ...

Better cron output handling? ▻