mail check at login

Heya all.

I have 2 main linux pc's.  One is a mail server among other
things, and the other is the pc users login to.

When they login they always get the message
"you have no new mail" as it is checking for email on the
wrong PC.

I want the pc users login to, to do it's mail check on
the mail server.  How is this setup? if at all?

Thanks!
Andrew

q@qonline.com.au
LVL 1
Q010797Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ahoffmannCommented:
Environment variable MAIL must point to users mail spool file, for example: /var/spool/mail/user1
This variable is usually set in the (login-) shell's startup file
(/etc/csh.{login.cshrc}, /etc/profile, etc.)
0
Q010797Author Commented:
But the mail spool files are on a different PC.
I don't want to mount /var/spool/mail from the other PC also.
So i want a way to do this.
0
spjuverCommented:
The question is what you really want...

You can add an .hushlogin file in the users home directory to switch the local mail facility.

Then run a program like fetchpop in a script to just check for mail on the mail server. This script can echo the 'You have new mail' or similiar.

Alternative 2 is to simply use the pop3 client to fetch all mails to the local machine at login. Then the login message will be correct...
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Q010797Author Commented:
Ahhh ok..

First option sounds best..

All i need to know now, is HOW to do this.  Where do I get the software and how do I set it up.

Lastly, how do I REMOVE the current mail check that says 'You have no new mail'.
0
ahoffmannCommented:
> Lastly, how do I REMOVE the current mail check that says 'You have no new mail'.

You have to use an other login :-(
0
spjuverCommented:
Wrong ahoffman, add a .hushlogin file in the home directory and you will get rid of that message.

ftpsearch.ntnu.no is a perfect server to find files if you only know the name of the file or a part of the name.

What you need is a pop client. Fetchmail gives a return code depending of if you have mail or not on the mail server.

Fetchpop is more powerful but have no proper return codes and needs a script with 'greps' out the neccesary information from what the fetchpop program returns.

I propose that you should use the fetchpop program and simply echo the return messasge at login.

It will show a line like:
> fetchpop -c
fetchpop 1.9pl1 release, by Seung-Hong Oh.
using mailbox folder /var/spool/mail/<user>
Checking mail, not fetching.
You have 0 new messages and total of 0 messages.


You can also just show the last line by make a script which re-formatt the message.

0
ahoffmannCommented:
Right sp.juver. I forgot that we are in a Linux (not UNIX) topic ;-)
0
Q010797Author Commented:
instead of putting a .hushlogin in EVERYONES home dir.. can I make it default for ALL users?
0
spjuverCommented:
I'm afraid that all users must have a .hushlogin.

That's no problem you don't need to make it.

put a 'touch $HOME/.hushlogin' in the system files for the shell's and it will be created if it don't exist when someone logs in...
0
Q010797Author Commented:
what if the users logging in are running pppd straight away, via AUTOPPP... how then do I make them run
touch $HOME/.hushlogin
on login?

0
Q010797Author Commented:
Also.. I have just tried out fetch pop..

All is well except I have to setup each users username and password for the accounts.  This could take weeks.

Any other options ?  btw.. the password and shadow files are the SAME on the pop3 machine, and the dialin machine
0
spjuverCommented:
Comment one:

It is the login process which is looking for the .hushlogin file.
The login process will place the user in his home directory and in that directory will be checked for .hushlogin.
If this directory is on the server, the server is running the login process. This means that your nice script should be on the server.

If the login procedure is done on the client then you ofcourse have to put the script on the client.

Comment 2:
I didn't say that you had to use fetchpop but if you really want to check mail at login and the mail are on another server you have to login on that server. Login is a security thing and must be set up per user - sorry.

If you want to fetch things as a single user without password use dos....
0
spjuverCommented:
Comment one:

It is the login process which is looking for the .hushlogin file.
The login process will place the user in his home directory and in that directory will be checked for .hushlogin.
If this directory is on the server, the server is running the login process. This means that your nice script should be on the server.

If the login procedure is done on the client then you ofcourse have to put the script on the client.

Comment 2:
I didn't say that you had to use fetchpop but if you really want to check mail at login and the mail are on another server you have to login on that server. Login is a security thing and must be set up per user - sorry.

If you want to fetch things as a single user without password use dos on the server....
0
Q010797Author Commented:
Surely if the password and shadow files on the 2 machines is the same, there is some software that will allow me to do the mail check at login.
0
Q010797Author Commented:
Surely if the password and shadow files on the 2 machines is the same, there is some software that will allow me to do the mail check at login.
0
spjuverCommented:
How is the mails stored on the other machine??
Is they stored in /var/spool/mail/<username> ??

Normal users on that machine with other words. Then simply use finger in a login script (still need to formatt the output if you only want new-mail-part)....

You should rewrite your question so one can answer properly...
0
Q010797Author Commented:
Yea that's getting there...  but how do I make it do that for
ALL users regardless of their login?

For that option to work they'd need to be running a script at login and some users (most) login using AUTOPPP and don't execute a script.
0
spjuverCommented:
After login all users must have a shell. This shell have always two startup-scripts. One in the home directory and one for the system. You can add 'finger $LOGNAME@your.nice.server' in the system file on the machine the shell is running...


0
Q010797Author Commented:
no.. some users use mgetty's AUTOPPP setup..  so for them there
is no way to run a login script.  For these users, how do I get the mail check running and/or other items at login?
0
spjuverCommented:
Don't matter which 'getty' you are using. The procedure after getty is login and then a shell.

I use mingetty for my console and agetty for my null-modem-link.
0
Q010797Author Commented:
no you don't get it...  mgetty uses AUTOPPP (pap and chap style) so I can't run login scripts with it the same way I do with people who use terminal windows and scripts etc....
0
c4lv1nCommented:
There are many several ways to get your mail local or pseudo-local. If you use NFS to mount your user directories from the server into your workstation (this is the way I prefer) and setup up NIS for central administrating users all mail stay on the server and seems to be local.
But the most easiest way is to use fetchmail. This is a program or deamon (optionally) whitch gets your mail from all mail-accounts. Using fetchmail on the server means that the specified users can get ALL their mail from one server. Try and be glad to use Linux...
0
Q010797Author Commented:
I read that answer and still have no idea what to do.  Sorry, just don't understand it.  Can you explain to me how I'd go about installing your suggestion ?
0
remsteveCommented:
OK - I read all this carefully and here is my view...

(i) You cannot do what you are asking for 90% of your users.
(ii) You are not testing your setup properly.

(i) As you correctly say, mgetty/AutoPPP DOES NOT INVOKE  login or a shell - pppd is started directly.  Therefore all login commands/options are igonored (except maybe ppp stuff).  In a sense these users do not "login" - they merely establish a network connection.  You cannot run scripts for them at 'connect-time'.

(ii) Remember to test you changes using an AutoPPP account - it sounds to me like you are testing with a terminal!
0
Q010797Author Commented:
Nah.. that sounds like an observation to me anyway.. not an answer..

Can spjuver please offer an answer again . . I'll give him the points . .he's been more helpful than others... and I've not got the problem sorted out anyway.. but know more about my problem than before
0
alexbikCommented:
Hi,

In my opinion, there are three solutions, but only one 'neat' one.

1) Disable the whole mail notification all together. There is probably a 'biff y' statement in your /etc/profile, change it to 'biff n'.

2) Install a perlscript that checks for mail on the remote server. The easiest way to do this is to make use of the finger daemon on the mailserver, in that way you don't have to know the user's password to see if he/she has mail waiting.

3) (The neat one):
As you mention that one server does the e-mail and the other is used for logins, I assume that you have some authentication protocol like NIS(+) running?
If the users on both machines are the same, you can export /var/spool/mail on the mailserver, and NFS mount it under /var/spool/mail on the other. In that way, it really doesn't mather on which machine a user is on, mail is available on all systems. Since your filesystem doesn't know usernames (only UID's), this option is only usable if all users have the same UID on both machines. This is not a bad idea anyway, and done automatically if you run NIS.

If you should choose option 2), here's an example of a shell script that does the job:

#!/bin/bash
remote_machine="mailhost.domain.com"
nomail=`finger $LOGNAME@$remote_machine | grep "No mail."`
if [ -z "$nomail" ] ; then
        echo "You have mail on server $remote_machine."
else
        echo "You have no mail."
fi

Please not that I wrot this script in a few minutes, and it does not check if the user has an account on the mailhost or not. If this situation could occour in your case, you need to add a check on this. If I understand your situation right, it should work fine for you.

Alex.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Q010797Author Commented:
biff doesn't work like that . . biff is for mail notification whilst logged in . . the mail check AT login has nothing to do with biff . .

But the answer is good enough anyway :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.