Little bash programming

Kevin Brown plug-discuss@lists.plug.phoenix.az.us
Tue, 09 Jul 2002 23:49:16 -0700


> Nice! To me, bash and the GNU tools are at
> least 50% of why I can't be as productive
> on MS. This is the sort of thing that makes
> advanced Windows users go, "oooh, that's
> pretty cool."
> 
> Wanna do a presentation or demo of CLI-power
> at Install Fest?
> 
> my favorite quickie for new users:
> 
> $ apropos file
>     (too many results)
> $ apropos file | grep -i compress
>     (ahh, that's better)

hmm, never knew about that command.

Of course part of my problem is that in a 10 hour period I spend my time working
on/dealing with WinNT/2k/98/98SE/95, Linux (RH distros 6.0 - 7.3) and SunOS
(2.5, 2.7, 2.8 and soon 2.9) on hardware ranging from my poor little P150 Laptop
up to Quad Sparc II Sun E450 servers.  So far I've only learned enough in each
of the OSes to be able to do basic things (Network config, GUI config, system
maintenance, some security [firewalls, stopping services, etc...]).  On top of
that I also have been learning SQL, snort, PHP, perl, Lightwave3D and more.

I've been using Linux since RH4.2 was out and still only seem to know just
enough to get myself in trouble, heheh.

> Let's see you try that on Windows :)

> > Came home tonite and got onto my Workstation and noticed that my IceWM session
> > from the server was gone.  Sometimes it disappears because the two boxes lose
> > contact with each other.  So I logged into the box and exported the DISPLAY
> > varaiable and restarted IceWM.  Then it occured to me that I could make this
> > much easier for myself.
> >
> > Played around with ps, grep, and awk and got something that would find the users
> > who have icewm running.  X is never run directly on the box because the only
> > time I sit at it is if it goes down.  So, I decided to muck with my
> > .bash_profile and see if I could auto fire off icewm from me just logging in.
> > Short story made shorter, yep.  Only a little basic thing, but since I rarely do
> > any coding (shell or otherwise) I think it was pretty good.  Great thing is, it
> > will only fire up icewm if I don't already have a copy up.
> >
> > username=`ps -ef | grep <username>.*[0-9].icewm | awk '{print $1}'`
> >
> > if [ ! Xhellgate = X$username ]
> > then
> >         echo "IceWM not running on your display"
> >         export DISPLAY=<my ip>:0.0
> >         icewm &
> > fi
> >
> > Guess I can later try and add some more sanity checking, but this works for now
> > :)