[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

168.0. "batch vs sys$output (help!)" by REX::MINOW () Tue Oct 15 1985 01:42

The story so far: I have written a simple little .COM file to
check for new mail on an infrequently visited node and, should
anyone bother writing me there, NMAIL the junk to my real node.
The interesting part of the command file is sort of as follows:
(We know that temp.tmp doesn't exist and MAIL/OUT=TEMP.TMP doesn't work)

$	assign/user temp.tmp sys$output:
$	mail
$	open/read/error=nomailfile check_tmp temp.tmp
$ read:	read/end=nomail check_tmp line
$	if 'f$locate("You have", line) .eqs. 'f$length(line) then goto read
$	close check_tmp
$	exit			! Here if there's mail (does NMAIL stuff)
$ nomailfile:			! Here if there's no mail waiting
$ write sys$output f$message($status)
$ exit				! File not found
$ nomail: exit			! Here if something funny happens

This works fine interactively (@foo.com), but doesn't create
the file in batch ($SUBMIT foo.com).

Any ideas or work-arounds?

Martin.

T.RTitleUserPersonal
Name
DateLines
168.1JON::MORONEYTue Oct 15 1985 02:237
Easy work-around, for you.  Get on your rarely visited node, type MAIL
and then type SET FORWARD node::user at the MAIL> prompt.  The next time
someone sends mail to the first node, it will get forwarded to you automagicly.

Isn't that easy?

-Mike
168.2REX::MINOWTue Oct 15 1985 11:237
I tried that and the lovely network refused to forward mail unless
the path was up and  running 100% of the time.  This method works
if the network is up at any time.   Also, if the network fails,
the sender is notified that I've moved, which is not necessarily
what I want the sender to know.

Martin.
168.3SARAH::A_VESPERTue Oct 15 1985 11:509
Could you forward to NM%martin::minow?

This tells mail (I don't know how) that the message is to be sent
using the NMAIL facilities.  This will retry every hour until the
network is up.

If you try this, please let us know if it works or not.

Andy V
168.4REX::MINOWTue Oct 15 1985 15:1212
forward nm%rex::minow doesn't work -- can't find NM_MAILSHR.EXE.

Note that the DCL problem remains -- I might want to change the
working part of the program to examine incoming mail automatically
and automatically file network news for me.  The problem is, I
can't get the guts to work if I can't handle the file creation
stuff.

Remember, this is the hacker's notesfile, not the "how to use mail"
notesfile.

Martin.
168.52CHARS::GOODRICHTue Oct 15 1985 16:2520
  Re: .4  ``I can't get the guts to work...''

  I assume it has to do with the way MAIL outputs its ``You have new mail''
  message.  If you look at the log file without the $ASSIGN, you won't see it
  there either.  Under Batch it seems to go to the NL: device.

  Here's what I'd hack for a batch file to check for newmail on a remote node:

  $ del temp.tmp;*		! assure no temp files left around
  $ mail			! let Mail check for new mail the hard way
  Sel Newmail
  Ext/all/mail temp.tmp
  $ open/read/error=nomailfile check_tmp temp.tmp  ! now we're back in business

  Thus if you have new mail, it's already in TEMP.TMP ready to be NMAIL'ed. If
  you don't, MAIL won't create a TEMP.TMP file since no messages were selected
  to be extracted.

MarkG.

168.6VAXUUM::DYERTue Oct 15 1985 16:587
	Like it says in Reply #5, the "You have X new messages"
does not appear to be displayed when MAIL is run in batch mode.
Fortunately, the solution is simple:  The SELECT NEWMAIL command
will tell you if you have new mail.  If you do, the TEMP.TMP file
will have a %MAIL-I-SELECTED message in it.  If there's no mail,
you'll get a %MAIL-E-NOTEXIST message.
		<_Jym_>
168.7REX::MINOWTue Oct 15 1985 18:446
.5 seems to have done the trick.  look for WATCHMAIL.COM at a toolshed
near you.  (I probably should "internationalize" the program so it
forces the message to have the %MAIL-I-SELECTED or %MAIL-I-NOTEXIST
but it seems to be ok for now.)

Thanks Mark and Jym.
168.8KAHLUA::BLOOMWed Oct 16 1985 15:4250
I use the following DCL procedure to check for new messages.  It requires
read access to VMSMAIL.DAT, with privs, or file protection.

/Eric

$ !++
$ !
$ !  CNM.COM - Look for new mail messages
$ !
$ !  REQUIRED PRIVILEGES:
$ !		READALL
$ !		
$ !  IMPLICIT INPUT:
$ !		SYS$SYSTEM:VMSMAIL.DAT
$ !
$ !--
$	close = "CLOSE"
$	exit = "EXIT"
$	goto = "GOTO"
$	if = "IF"
$	on = "ON"
$	open = "OPEN"
$	read = "READ"
$	write = "WRITE"
$!
$	prev_priv = F$SETPRV("READALL")
$	sysmai = f$parse("VMSMAIL","SYS$SYSTEM:.DAT;")
$	OPEN /READ /SHARE file 'sysmai'
$	ON CONTROL_Y THEN GOTO done
$!
$	username = F$GETJPI("","USERNAME")
$	IF p1 .NES. "" THEN $ username = "''p1'"
$!
$	READ /INDEX=0 /ERR=no_user /KEY="''username'" file record
$	msgs = F$CVUI(33*8, 16, record)
$	username = F$EDIT(username, "TRIM")
$	IF p1 .EQS. "" THEN $ GOTO me
$	outstr = F$FAO("User !AS has !UL new message!%S.", username, msgs)
$	WRITE SYS$OUTPUT outstr
$	GOTO done
$me:	outstr = F$FAO("You have !UL new message!%S.", msgs)
$	WRITE SYS$OUTPUT outstr
$	GOTO done
$no_user:
$	WRITE SYS$OUTPUT "No such user ''username', or ''username' has no new mail."
$	GOTO done
$done:
$	CLOSE file
$	prev_priv = F$SETPRV(prev_priv)
$	EXIT
168.9BAGELS::ROSENBAUMMon Oct 21 1985 01:598
related gotcha...

Unless things have changed under V4, MAIL will not work as a network job
(for instance, define your own .COM object that, among other things, mails you a
message).  Running as a network process, Mail assumes that it should set up to
receive incoming mail from a remote node.

__Rich
168.10TBD::ZAHAREEMon Oct 21 1985 17:118
re .9

"(for instance, define your own .COM object that, among other things, mails you
 a message)." 

However, it can be done from a suprocess of the network job.

- M
168.11SMAUG::THOMPSONMon Oct 21 1985 21:128
WRT:  nm%node::user

You need the latest version of NMAIL, this is a re-write in Bliss of
the original command procedure.

You can do set forward, so you don't need to worry about the net.

Mark