logo       

Re: Re: Running commands from bash in an xterm when logging-in (to X sessio: msg#00003

Subject: Re: Re: Running commands from bash in an xterm when logging-in (to X session)?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Magnus Therning wrote:
> On Thu, Oct 27, 2005 at 11:12:00PM +0100, 
> dean-DffCPKo7/b1AfugRpC6u6w@xxxxxxxxxxxxxxxx wrote:
> 
>>-----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`
> 
> 
> Personally I'd use `pgrep`, but the above would work as well.
> 
> 
>>if [ -z "$RUNNING" ]
>>then
>>cat ~TODO
>>fi
>>
>>
>>It saves creating a temporary file and using the crontab then.
> 
> 
> It all comes down to what kind of behaviour you want "once-per-login"
> (the first option, actually more like "once-per-boot"), "once-per-day"
> (use crontab). Yours is more like "everytime-bash-is-lonely" (in lack of
> a better description).
> 
> /M
> 
> 
Heh, I guess that comes to me assuming that everyone behaves the same as
me - and always has bash running somewhere, from power-on to power-off.

Dean
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDZ+0NeedO8dcp9nYRArd7AJ9/1COy1PIMN+z+NJTROxxQBv5gMwCbBZQh
iEAY1S5vTqyMTLgPy14dmlI=
=Tw/k
-----END PGP SIGNATURE-----



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe