Have you ever opened pine and it sits there spinning it's wheels, not being able to get
a lockfile, and then it goes to read only mode? And you think, "Oops, I already had pine
open!" Well, that's exactly what this script is for. There are countless variations of it
on the internet. Just a little "Googling" and you'll see. People checking to see if their
server is up and running, a database program, whatever, and if not, restart the program.
All you need is this script and an alias in your .profile to make for less typing, and
you're good to go.
#!/bin/sh
TEST=`pgrep $1`
if [ ! "$TEST" ]
then
$2
else
echo "$1 is Alive, Dummy! "
fi
Now all you need to do is put an alias in your ~/.profile, something like this:
pine='~/yourscriptname pine /usr/local/bin/pine'
Refresh your ~/.profile:
$~ . ./.profile
Check to see if the alias is in force:
$~ alias |grep pine
Okay, you're good to go. Type pine, pine comes up, hit Ctrl-Z to shell to a terminal
prompt, try running pine again and, whoops, would you look at that:
$~ pine is Alive, Dummy!
Just type fg, hit enter, and there you are, back in pine.
I had to do it slightly differently on my other box, since I use mutt for my email there.
In ~/.profile, I put:
mutt='~/yourscriptname mutt "/usr/local/bin/mutt -f =inbox"'
Mutt operates a little differently than pine. If I didn't put the ""'s around the command,
regardless of what I'd told it to do, I'd have wound up in the base ~/Mail directory,
rather than in my inbox.
Back to Tips and Tricks
Home
No affiliation between this site and the OpenBSD project exists or is implied.