[Novices] very simple at commands

Bruce Smith bruce at armintl.com
Tue Feb 22 17:44:29 EST 2005


> Oh, right, piping.  I reckon I could do that.  (If I remember, and 
> remember to enclose the command I want to pipe into "echo".)
> 
> Hmn.  How might I (or you!) write a shell script that takes an at-like 
> time spec and a command line and does the command at the time?  I 
> *think* using that script would be easiest for me to remember later, and 
> anyway it would be a good lesson for me in shell scripting.  A script 
> 'doat' where I could type
> 
> 	$ doat now + 1 minute echo "Go to the meeting"

------------------------
#!/bin/sh
sleep 60
echo "Go to the meeting"
------------------------

:-)

> That would seem hard to code up.  Maybe easier with a '-c' between them 
> (though that would also take remembering).

You could make the number of seconds "$1" and supply the seconds as
parameter #1.

Or you could multiply it by 60 in the script so you can supply minutes
instead of seconds.

If you really want to get fancy with "now" and such on the command line,
it's possible but could take some work.  Right not you haven't motivated
me enough to write such a thing, so that's your homework!  :-)

> Also, I had forgotten (or never knew) that standard output of at gets 
> mailed.  I don't often use it for echo, as in my example, but is there 
> any way to send it to the invoking terminal instead?

Forget "at" and run the above script in the background on the terminal.
(append a "&" to the end of the command)

> Maybe I should just remember ^D.  I used to use it 15 years ago for 
> writing email, after all.  But I can't think of another case where I use 
> it today.

Anywhere you need a end-of-file.
^D is nice to end a terminal window too.

 - BS




More information about the Novices mailing list