dean at deansas.org
dean at deansas.org
Thu Oct 27 17:12:00 CDT 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Magnus Therning wrote:
> On Thu, Oct 27, 2005 at 12:25:14PM +0100, Chris Beauchamp wrote:
>
>>Magnus Therning wrote:
>>
>>
>>>What you could do is make sure it's only done once, i.e. for the first
>>>terminal that's started. Sticking something like this in ~/.bashrc might
>>>do:
>>>
>>> [[ -f /tmp/todo_done ]] || ( cat ~/TODO; touch /tmp/todo_done )
>>
>>Of course, this will only ever display it once, and for only one user...
>>a refinement maybe:
>>
>>
>>[[ -f /tmp/todo_done$USER ]] || ( cat ~/TODO; touch /tmp/todo_done$USER )
>>
>>and in /etc/crontab
>>
>>0 6 * * * root rm /tmp/todo_done*
>>
>>to delete all the flags at 6am
>
>
> It might be further refined for multi-user use:
>
> [[ ! -f /tmp/todo_done$USER -a -f ~/TODO ]] && \
> ( cat ~/TODO; touch /tmp/todo_done$USER )
>
> That can then be put in /etc/bash.bashrc.
>
> /M
Hi,
Couldn't you just do this (I've not tested either of these btw):
RUNNING=`ps | grep bash | grep -v grep`
if [ -z "$RUNNING" ]
then
cat ~TODO
fi
It saves creating a temporary file and using the crontab then.
Failing that then
RUNNING-`ps | grep bash -c`
# two, one for the bash shell that is executing this file, and
# one to match the grep and
if [ "$RUNNING" -eq 2 ]
then
cat ~TODO
fi
Regards,
Dean
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDYVCweedO8dcp9nYRAo8NAJ0UmfobPY7T0S5tCfJ/ER+L4KMioACfUVaa
emTDngu3y3ZaDjJzLttXoQc=
=Olcj
-----END PGP SIGNATURE-----
More information about the ubuntu-uk
mailing list