Re: multiple mutts

2000-10-11 Thread Mikko Hänninen

the/eXtreme [EMAIL PROTECTED] wrote on Wed, 11 Oct 2000:
 I could use a shell script to `ps' for existing
 mutt sessions before launching another session;
 or is there a better way?

How about a shell script that looks (vaguely) like this:

#!/bin/sh
LOCKFILE=~/.mutt.lock
if [ -f $LOCKFILE ]; then
  echo "Another Mutt session is already running ($LOCKFILE exists)"
  exit 1
else
  touch $LOCKFILE
  mutt $*
  rm $LOCKFILE
fi


... That's untested, I just typed it in, but hopefully it will work.
At the very least, with minor tweaking.


Hope this helps,
Mikko
-- 
// Mikko Hänninen, aka. Wizzu  //  [EMAIL PROTECTED]  //  http://www.iki.fi/wiz/
// The Corrs list maintainer  //   net.freak  //   DALnet IRC operator /
// Interests: roleplaying, Linux, the Net, fantasy  scifi, the Corrs /
Meep!



Re: multiple mutts

2000-10-11 Thread Suresh Ramasubramanian

the/eXtreme proclaimed on mutt-users that: 

 I could use a shell script to `ps' for existing
 mutt sessions before launching another session;
 or is there a better way?

That is the best way ;)

-- 
Suresh Ramasubramanian + Wallopus Malletus Indigenensis
mallet @ cluestick.org + Lumber Cartel of India, tinlcI
Come quickly, I am tasting stars!
-- Dom Perignon, upon discovering champagne.



Re: multiple mutts

2000-10-11 Thread Bruce DeVisser

On Wed, Oct 11, 2000 at 11:49:40AM -0500, the/eXtreme wrote:
 Hey, sometimes I shell out of a mutt window,
 forget where I am (easy, when you're me),
 and start another mutt session.  Days can go
 by before I catch the duplicated sessions.
 
 I could use a shell script to `ps' for existing
 mutt sessions before launching another session;
 or is there a better way?

Assuming for the sake of this example a bash shell:

You could create a .muttbashrc file which, after sourcing your regular
rc file, says
PS1="mutt-shell: "
and then in mutt (or your .muttrc)
:set shell="/bin/bash -rcfile /home/username/.muttbashrc"

But if you open more subshells, you're on your own. :)

-- 
- Bruce



Re: multiple mutts

2000-10-11 Thread the/eXtreme

-: LOCKFILE=~/.mutt.lock

Does a lock file exist for IMAP-configured mutt?  When I
have a mutt session up, I can't find a lock file anywhere.

Do I need to be concerned with the `dotlock_program'
configuration variable?  My configuration and build
of mutt-1.2.5 didn't create a `mutt_dotlock' binary.

TIA



Re: multiple mutts

2000-10-11 Thread Conor Daly

On Wed, Oct 11, 2000 at 02:30:07PM -0500 or thereabouts, the/eXtreme wrote:
 -: LOCKFILE=~/.mutt.lock
 
 Does a lock file exist for IMAP-configured mutt?  When I
 have a mutt session up, I can't find a lock file anywhere.
 
 Do I need to be concerned with the `dotlock_program'
 configuration variable?  My configuration and build
 of mutt-1.2.5 didn't create a `mutt_dotlock' binary.
 
 TIA

You'll notice the previous post includes the line

touch $LOCKFILE

This will create such a lockfile when you run the script.  mutt does not
create a lockfile by default.

-- 
Conor Daly 
Met Eireann, Glasnevin Hill, Dublin 9, Ireland
Ph +353 1 8064217 Fax +353 1 8064275




Re: multiple mutts

2000-10-11 Thread the/eXtreme

-: You'll notice the previous post includes the line
-: 
-: touch $LOCKFILE

Yes, silly of me.  It also helps if the luser starts
the *first* mutt session using the script.  Duh.



Re: multiple mutts

2000-10-11 Thread Conor Daly

On Wed, Oct 11, 2000 at 03:33:06PM -0500 or thereabouts, the/eXtreme wrote:
 -: You'll notice the previous post includes the line
 -: 
 -: touch $LOCKFILE
 
 Yes, silly of me.  It also helps if the luser starts
 the *first* mutt session using the script.  Duh.

Time of day, Time of day...
-- 
Conor Daly 
Met Eireann, Glasnevin Hill, Dublin 9, Ireland
Ph +353 1 8064217 Fax +353 1 8064275




Re: multiple mutts

2000-10-11 Thread Brian Salter-Duke

On Wed, Oct 11, 2000 at 08:19:24PM +0300, Mikko Hänninen wrote:
 the/eXtreme [EMAIL PROTECTED] wrote on Wed, 11 Oct 2000:
  I could use a shell script to `ps' for existing
  mutt sessions before launching another session;
  or is there a better way?
 
 How about a shell script that looks (vaguely) like this:
 
 #!/bin/sh
 LOCKFILE=~/.mutt.lock
 if [ -f $LOCKFILE ]; then
   echo "Another Mutt session is already running ($LOCKFILE exists)"
   exit 1
 else
   touch $LOCKFILE
   mutt $*
   rm $LOCKFILE
 fi
 
 
 ... That's untested, I just typed it in, but hopefully it will work.
 At the very least, with minor tweaking.

This is the ps solution that I use all the time. I and Rob Reid
developed this some time ago. I call the mutt exectuable realmutt, this
script muttwrap and alias 'mutt' to 'muttwrap -y'.

I know you can open several mutts and write in all of them, but I prefer
to open the 2nd in readonly to remind me that I really did not want to
do it in most cases and if I did it could be in readonly mode.
 
#!/usr/bin/sh
if ps -U $LOGNAME | grep realmutt  /dev/null 
then
echo Warning: You are already running Mutt.
echo Starting mutt in readonly mode.
sleep 2 # Or however many seconds you need to read the
# message before mutt starts.
/usr/local/bin/realmutt -R $*
else
echo Starting Mutt OK
sleep 2
/usr/local/bin/realmutt $*
fi

Cheers, Brian.

 
 Hope this helps,
 Mikko
 -- 
 // Mikko Hänninen, aka. Wizzu  //  [EMAIL PROTECTED]  //  http://www.iki.fi/wiz/
 // The Corrs list maintainer  //   net.freak  //   DALnet IRC operator /
 // Interests: roleplaying, Linux, the Net, fantasy  scifi, the Corrs /
 Meep!

-- 
Associate Professor Brian Salter-Duke (Brian Duke) [EMAIL PROTECTED]  
  School of Biological, Environmental and Chemical Sciences, SITE,
Northern Territory University, Darwin, NT 0909, Australia.  Phone 08-89466702. 
Fax 08-89466847  http://www.smps.ntu.edu.au/school/compchem.html



Re: multiple mutts

2000-10-11 Thread Bruce J.A. Nourish

 if ps -U $LOGNAME | grep realmutt  /dev/null 

Be careful about using grep to search the output of ps. For example

$ ps ax | grep lemming
16004 tty1 S  0:00 grep lemming

Y'see? Grep makes a match on its own process.

-- 
[ Bruce J.A. Nourish (email and finger) [EMAIL PROTECTED]]
[ GPG key ID BE062236 (75C2 6784 B600 F7F4 E35E  A039 F62C 5AC7 BE06 2236) ]
[ Fax (775) 665-5938 Phone (480) 763-6970 Pgr (602) 201-3376, ICQ 38344897 ]
[ Web http://www.kode187.net - Postal: PO Box 51611, Phoenix AZ 85076-1611 ]



Re: multiple mutts

2000-10-11 Thread Brian Salter-Duke

On Wed, Oct 11, 2000 at 04:38:31PM -0700, Bruce J.A. Nourish wrote:
  if ps -U $LOGNAME | grep realmutt  /dev/null 
 
 Be careful about using grep to search the output of ps. For example
 
 $ ps ax | grep lemming
 16004 tty1 S  0:00 grep lemming
 
 Y'see? Grep makes a match on its own process.

It works OK on AIX 3.2.5 ps. If you add the -f flag it finds the grep
line, but it does'nt without it.

OK, so maybe my script does'nt work on all systems, but it is worth
playing with to see if some set of ps flags works as required.

Cheers, Brian.
 
 -- 
 [ Bruce J.A. Nourish (email and finger) [EMAIL PROTECTED]]
 [ GPG key ID BE062236 (75C2 6784 B600 F7F4 E35E  A039 F62C 5AC7 BE06 2236) ]
 [ Fax (775) 665-5938 Phone (480) 763-6970 Pgr (602) 201-3376, ICQ 38344897 ]
 [ Web http://www.kode187.net - Postal: PO Box 51611, Phoenix AZ 85076-1611 ]

-- 
Associate Professor Brian Salter-Duke (Brian Duke) [EMAIL PROTECTED]  
  School of Biological, Environmental and Chemical Sciences, SITE,
Northern Territory University, Darwin, NT 0909, Australia.  Phone 08-89466702. 
Fax 08-89466847  http://www.smps.ntu.edu.au/school/compchem.html



Re: multiple mutts

2000-10-11 Thread Aaron Schrab

At 09:23 +0930 12 Oct 2000, Brian Salter-Duke [EMAIL PROTECTED] wrote:
 On Wed, Oct 11, 2000 at 04:38:31PM -0700, Bruce J.A. Nourish wrote:
   if ps -U $LOGNAME | grep realmutt  /dev/null 
  
  Be careful about using grep to search the output of ps. For example
  
  $ ps ax | grep lemming
  16004 tty1 S  0:00 grep lemming
  
  Y'see? Grep makes a match on its own process.
 
 It works OK on AIX 3.2.5 ps. If you add the -f flag it finds the grep
 line, but it does'nt without it.
 
 OK, so maybe my script does'nt work on all systems, but it is worth
 playing with to see if some set of ps flags works as required.

Or you could just make a minor modification to the grep pattern:

  ps -U $LOGNAME | grep 'r[e]almutt'  /dev/null

That way grep won't be able to match itself.

-- 
Aaron Schrab [EMAIL PROTECTED]  http://www.execpc.com/~aarons/
 Besides, including std_ice_cubes.h is a fatal error on machines that
 don't have it yet.  Bad language design, there...  :-)--Larry Wall



Re: multiple mutts

2000-10-11 Thread Brian Salter-Duke

On Wed, Oct 11, 2000 at 07:17:35PM -0500, Aaron Schrab wrote:
 At 09:23 +0930 12 Oct 2000, Brian Salter-Duke [EMAIL PROTECTED] wrote:
  On Wed, Oct 11, 2000 at 04:38:31PM -0700, Bruce J.A. Nourish wrote:
if ps -U $LOGNAME | grep realmutt  /dev/null 
   
   Be careful about using grep to search the output of ps. For example
   
   $ ps ax | grep lemming
   16004 tty1 S  0:00 grep lemming
   
   Y'see? Grep makes a match on its own process.
  
  It works OK on AIX 3.2.5 ps. If you add the -f flag it finds the grep
  line, but it does'nt without it.
  
  OK, so maybe my script does'nt work on all systems, but it is worth
  playing with to see if some set of ps flags works as required.
 
 Or you could just make a minor modification to the grep pattern:
 
   ps -U $LOGNAME | grep 'r[e]almutt'  /dev/null
 
 That way grep won't be able to match itself.

Clever! It works well.

Brian.
 
 -- 
 Aaron Schrab [EMAIL PROTECTED]  http://www.execpc.com/~aarons/
  Besides, including std_ice_cubes.h is a fatal error on machines that
  don't have it yet.  Bad language design, there...  :-)--Larry Wall

-- 
Associate Professor Brian Salter-Duke (Brian Duke) [EMAIL PROTECTED]  
  School of Biological, Environmental and Chemical Sciences, SITE,
Northern Territory University, Darwin, NT 0909, Australia.  Phone 08-89466702. 
Fax 08-89466847  http://www.smps.ntu.edu.au/school/compchem.html



Re: multiple mutts

2000-10-11 Thread raf

Jamie Novak wrote:

 On 10/11, Aaron Schrab rearranged the electrons to read:
 
  Or you could just make a minor modification to the grep pattern:
  
ps -U $LOGNAME | grep 'r[e]almutt'  /dev/null
  
  That way grep won't be able to match itself.
 
 You could also just do a:
 
 ps -U $LOGONAME | grep mutt | grep -v grep  /dev/null
 
 "grep -v" tells grep to ignore whatever pattern you specify there.
 I haven't tested this on many versions of grep, but I know it works
 under AIX, HP-UX and FreeBSD.  YMMV.
 
 - Jamie

but that would be a waste of a process.

raf




Re: multiple mutts

2000-10-11 Thread Bob Bell

On Thu, Oct 12, 2000 at 09:23:29AM +0930, Brian Salter-Duke 
[EMAIL PROTECTED] wrote:
  Be careful about using grep to search the output of ps. For example
  
  $ ps ax | grep lemming
  16004 tty1 S  0:00 grep lemming
  
  Y'see? Grep makes a match on its own process.
 
 It works OK on AIX 3.2.5 ps. If you add the -f flag it finds the grep
 line, but it does'nt without it.
 
 OK, so maybe my script does'nt work on all systems, but it is worth
 playing with to see if some set of ps flags works as required.

I've been working a lot with ps in Tru64 UNIX and reading the Unix98
(Single Unix Spec V2) standards, and this is undefined behaviour.
Basically, ps takes a snapshot of the processes running at an instant in
time.  Depending on how it does this, and how the system manages
processes, the ps command itself may or may not show.  Some Unices will
even show it sometimes and not others.

-- 
Bob Bell [EMAIL PROTECTED]
-
 "The sooner you start to code, the longer the program will take."
   -- Roy Carlson, University of Wisconsin