Operating System - OpenVMS
1757733 Members
2204 Online
108863 Solutions
New Discussion юеВ

Notifying if file has been found by email

 
SOLVED
Go to solution
vmsserbo
Super Advisor

Notifying if file has been found by email

Hi,

I have attached a com file that searches a disk for any temporary RDMS files and deletes them. How do I include an email to notfy me, if it does in fact find a temporary RDMS file, so I won't have to always look at the log to see if it founf it or not.

Thanks!
7 REPLIES 7
Heinz W Genhart
Honored Contributor
Solution

Re: Notifying if file has been found by email

Hi Miles

I had only a short look at your attachement.
It seems to me, that you do there everything to recognize the condition for when to send a email.
So I assume you don't know how to send a email within a command procedure.

To do this:

$ Mail/subject="Your specific Text" NL: system

or

$ Mail/Subject="Your specific text" NL: smtp%"name@domain"

or

generate a output file e.g. mail_text.txt and send it with

$ Mail/Subject="Your specific text" mail_text.txt system


Hope it helps

Heinz
John Gillings
Honored Contributor

Re: Notifying if file has been found by email

Miles,

I'd suggest you write a jacket around your procedure. This is a general principle, "separation of concerns". There are two independent things here, one is doing the job, the other is reporting on it.

Capture the log file and mail it. Something like:

$ @WATCHER_FINDFILE_RDMSTMP.com -
/OUTPUT=sys$sysdevice:[central]watcher_findfile_rdmstmp.log
$ MAIL/SUBJECT="WATCHER FINDFILE" -
sys$sysdevice:[central]watcher_findfile_rdmstmp.log -
MILES

If you want to get more creative you could put logic in the procedure to work out if it was successful or not, and return a status code. You could then do something like this:

$ @WATCHER_FINDFILE_RDMSTMP.com -
/OUTPUT=sys$sysdevice:[central]watcher_findfile_rdmstmp.log
$ IF $STATUS
$ THEN
$ subj="WATCHER FINDFILE successful"
$ msg="NL:"
$ ELSE
$ subj="WATCHER FINDFILE failed, logfile attached"
$ msg="sys$sysdevice:[central]watcher_findfile_rdmstmp.log"
$ ENDIF
$ MAIL/SUBJECT="''subj'" 'msg' MILES
$ EXIT

So, if the job worked, you get an empty message with a subject that tells you it was successful. If it failed, you get the logfile for further investigation
A crucible of informative mistakes
Robert Gezelter
Honored Contributor

Re: Notifying if file has been found by email

Miles,

I agree with what John said, but I would even suggest going one step further.

Look up the appropriate OpenVMS status code (e.g. SS$_NOSUCHFILE or other). The equivalences for these symbolic values are in the include files used by the various languages, which you should find in SYS$LIBRARY (the files are packaged as text libraries; use the LIBRARY command to unpack the libraries for one of the languages and use the SEARCH command to find the symbolic definitions, the will be a series of symbols with the SS$_xxxx names).

Then, you will have more options available than a simple success/failure.

This is an approach that I recommended in my DECUS presentation from several years ago, entitled "DCL Lexicals: OpenVms Jujitsu" (see http://www.rlgsc.com/decus/usf95/index.html
)

- Bob Gezelter, http://www.rlgsc.com
John Abbott_2
Esteemed Contributor

Re: Notifying if file has been found by email

Hi Miles,

re: $ if f$file("find.''mypid'","eof") .nes. 0

(nes = not equal to string) you just need .ne. (not equal to for numbers) sorry being picky!

Personally I'd replace it with
$IF $SEVERITY .EQS. "3"
THEN take_no_match_found_action
ELSE matches_found_actions
ENDIF

We often use F$GETJPI("","PID") + others so rather than having to code it endless times, we declair them at login, e.g.

$ sh sym global$*
GLOBAL$ACCOUNT == "SYSTEM"
GLOBAL$CLUSTER == "PRODUCTION"
GLOBAL$DEFAULT == "SYS$SYSROOT:[SYSMGR]"
GLOBAL$HWPREFIX == "ALP"
GLOBAL$HWTYPE == "ALPH"
GLOBAL$LOGIN_DEVICE == "SYS$SYSROOT:"
GLOBAL$MODE == "INTERACTIVE"
GLOBAL$NODE == "ALPN"
GLOBAL$PID == "20407233"
GLOBAL$UIC == "[SYSTEM]"
GLOBAL$USERNAME == "xxxxxxxxxxxxx"

Finally, getting back to what you originally asked... if you're emailing to outlook or something else with a rules wizard, I'd think about planning ahead the format of your subject line. As time passes I suspect you'll end up with lots of emails. The rules wizard can be your friend in filing these into categories, priorities etc.

Hope this helps.
J.
Don't do what Donny Dont does
Karl Rohwedder
Honored Contributor

Re: Notifying if file has been found by email

Miles,

since VMS Mail does not display the subject line on the mailnotification, I often 'misuse' the /PERSONAL_NAME to specify the subject on such automated mails, so I know without opening the mail what's going on (if you start the string with you get it nicely on a separated line).

regards Kalle
B Claremont
Frequent Advisor

Re: Notifying if file has been found by email

My turn, my turn!

The DCL procedure template in this article offers another example of sending e-mail from within a procedure.

http://www.migrationspecialties.com/pdf/Using%20OpenVMS%20to%20Meet%20a%20Sarbanes-Oxley%20Mandate2.pdf
www.MigrationSpecialties.com
Wim Van den Wyngaert
Honored Contributor

Re: Notifying if file has been found by email

Hi again B.,

Just one remark, and not just for this procedure and not only for you.

It's better to trap starting at warning level.

This because the separation between warning and error is not perfect in VMS.

E.g.

dir a.b.c
-> warning
delete a.dir; while [a] contains files
-> warning
sea a.com bbb while a.com non-existing
-> warning
delete a.dat; while a.com open for write
-> warning

Fwiw

Wim
Wim