static char sccsid
[] = "@(#)netmail.c 4.1 (Berkeley) 9/12/82";
static char *netmail_sid
= "@(#)netmail.c 1.2";
netmail [-c] [-l ...] [-p ...] [-f] [-n] [-q] ([mach] | [mach:username])
Read mail on remote machine "mach"
Sends a command to the remote machine to "mail" the mail
If the -c option is specified, this command is a mail check command,
and in this mode it logs into the remote machine as "network"
and determines if mach:username has mail.
It writes/mails a message to that effect.
This variant is intended to be used in .login files, silently
checking if you have mail on another machine.
Must duplicate effort that will be redone by the net command-
the calls to commandfile and promptlogin are necessary
to get a value for the login name to send to the prmail
command on the other machine.
May read the passwd file:
1. Commandfile calls getenv(HOME) to get the home directory.
If not easily reached,....
2. SnCurrent() calls getlogin(). If no entry in utmp file,
char machparm
[BUFSIZ
], fromaddress
[BUFSIZ
], fMailCheck
= 0;
char rcmd
[BUFSIZ
], fquiet
= 0;
while(argc
> 0 && argv
[0][0] == '-'){
case 'b': status
.nonotify
++; appss(rcmd
,argv
[0]); break;
case 'c': fMailCheck
++; appss(rcmd
,argv
[0]); break;
case 'f': status
.force
++; appss(rcmd
,argv
[0]); break;
case 'l': harg(status
.login
); break;
case 'n': status
.nowrite
++; appss(rcmd
,argv
[0]); break;
case 'p': harg(status
.mpasswd
); break;
case 'q': fquiet
= 1; appss(rcmd
,argv
[0]); break;
"Usage: netmail [-l login] [-p password] [-c] [-f] [-n] [-q] [mach]\n");
if(FMemberSCh(argv
[0],':'))
remote
= MchSFromAddr(status
.login
,argv
[0]);
remote
= lookup(argv
[0]);
fprintf(stderr
,"Unknown machine %s\n",argv
[0]);
/* read the .netrc file to get a value for remote */
/* will get status.login, passwd, and force for fetch variant */
if(remote
== 0)remote
= getremote(local
);
sprintf(machparm
,"-m%c",remote
);
"Use the mail command to read your mail on this machine.\n");
/* read pw file, get local addr to send to prmail, store in status.localname */
fprintf(stderr
,"Unknown local user\n");
strcpy(status
.localname
,s
);
sprintf(fromaddress
,"%s:%s",longname(local
),s
);
if(status
.login
[0] == 0){
"Must supply a remote user name for mail check.\n");
/* send mail check over, no passwd needed */
mexecl(netcmd
,"net","-q",machparm
,"-l","network",
PRMAIL
,"-c","-l",status
.login
,"-f",fromaddress
,0);
mexecl(netcmd
,"net","-q",machparm
,"-l","network",
PRMAIL
,"-c","-l",status
.login
,"-f",fromaddress
,"-k",0);
fprintf(stderr
,"Network is down\n");
/* mail forward variant */
get name to send as parameter to prmail.
required for multiple login names with the same uid's
envloginpasswd(remote
,status
.login
,status
.mpasswd
); /* look in env */
promptlogin(remote
); /* prompt for name, passwd explicitely */
kexecl(netcmd
,"net","-q",machparm
,"-c",rcmd
,PRMAIL
,"-l",
status
.login
,"-f",fromaddress
,"-r",0);
kexecl(netcmd
,"net","-q",machparm
,"-c",rcmd
,PRMAIL
,"-l",
status
.login
,"-f",fromaddress
,"-r","-k",0);
fprintf(stderr
,"Network is down\n");
append string sfrom to end of string sto, preceded by blank */
register char *sto
, *sfrom
;