[comp.unix.programmer] how to check mail remotely : Summary

hui@shiva.trl.oz (Alvaro Hui) (12/04/90)

Hi,
	I post a question a few days ago asking how to check
mail remotely without logging in to the machine, here are the responses:
Unfortunately, only two of them.... BUT they all works fine for me!
Thanks Gordon and Matt for their response!

Enjoy!

========================================================================
From: ping!gorpong@uu.psi.com (Gordon C. Galligher)


One way is:  'rsh host ls -l /usr/spool/mail/myname'
This will give you a listing of the directory.  It would be nice to do:

	rsh host mail -e 

Which (if -e is supported) would cause 'mail' to exit with a non-zero
exit status if you have mail, but rsh is brain-dead.  It only returns
an exit status of non-zero if it could not make a connection, it does
not let you know the exit status of your remote command.  You could, however
embedd this, thus (NOTE:  these are one-line things, the '\' is for
readability):

    SH/KSH:
	status=`rsh host /bin/sh -c '(if test -s /usr/spool/mail/myname ; \
		echo 1 ; else echo 0 ; fi)'`
	if [ $status -eq 1 ] ; then echo 'You have mail on host' ; fi
		
    CSH:
    	set stat = `rsh ...same as above...`
	if ( $stat == "1" ) echo "You have mail on hosts"

Other than logging in, there is no other way.  If you are using NFS, and
the rexd program is enabled, then you can replace the 'rsh' above with
the 'on' command.  The 'on' command is intelligent enough to have a return
a status which is the same as the invoking program.  Therefore:
	(SH/KSH): if on host mail -e ; then echo 'You have mail on host' ; fi
	(CSH): if ( {on host mail -e} ) echo 'You have mail on host'

If, of course, you will be doing all of this from the command line, then
you might as well do:

	rsh host from
or	on host from

This will quickly let you know IF you have mail, and then who it is from.

I hope this all helps.

		-- Gordon.

-- 
Gordon C. Galligher	9127 Potter Rd. #2E	Des Plaines, IL    60016-4881
		     ...!{uupsi,uu.psi.com}!ping!gorpong
From: ma155fbd%sdcc14@ucsd.edu (Vegetable Man)

Well, I'm not sure how universal it is, but with all the unix
machines i've used, the mail is stored in the file 
/usr/spool/mail/<username>
so you can just ftp that file, if it exists, then you not only
find out about new mail, you can read it.  I do that with
work and school, at least.
I'm not sure where VMS puts unread mail, and ftp may not be
available on your DEC machines, so this is not the total
answer.

good luck,
matt
mbonner@ucsd.edu

ghe@comphy.physics.orst.edu (Guangliang He) (12/04/90)

This is how I check mail remotely. I have mush (6.0.3) running on the remote
machine. I then issue the following command on my local host:

rsh remote_host mush -i

It works fine. The only draw back is that I don't get the pager if a mail is
too big. But I use a Mac (How lucky), I can scroll back.
                            Guangliang He

                            ghe@PHYSICS.ORST.EDU
                            hegl@ORSTVM.BITNET

anagram@desire.wright.edu (Sh'r'ldana) (12/05/90)

> One way is:  'rsh host ls -l /usr/spool/mail/myname'
> This will give you a listing of the directory.  It would be nice to do:
> 
> /usr/spool/mail/<username>
> so you can just ftp that file, if it exists, then you not only
> find out about new mail, you can read it.  I do that with

The ftp is not really so good of any idea.  Depending on size and such, it
could take a long time.  

Also, the ls is kind of slow.  What I found works better (if supported) is to
use the from command.  In otherwords:

rsh host from

this is almost immediate, instead of relatively slow like the ls, and gives the
added benefit of telling you who the messages are from in case you need to
reply to some specific messages and want to let all others wait.

sh'r

nichols@en.ecn.purdue.edu (Scott P Nichols) (12/05/90)

In article <22018@orstcs.CS.ORST.EDU> ghe@PHYSICS.ORST.EDU.UUCP (Guangliang He) writes:
>
>            ...The only draw back is that I don't get the pager if a mail is
>too big. But I use a Mac (How lucky), I can scroll back.
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

Gee, my IBM scrolls back, too!!!

-- 
O-        /\
|\     /\/vv\
      /vv\   \        	      __Insight from Oregon...Scott P. Nichols
_____/    \   ~~~~~~~~~~~~~~~~                      (nichols@en.ecn.purdue.edu)