HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting ANA/SYS

 
SOLVED
Go to solution
Jack Trachtman
Super Advisor

Scripting ANA/SYS

I would like to use ANA/SYS in a script as follows

1) Create a one line cmd for ANA/SYS (for example, TCPIP SHOW DEV TNA6/FULL)

2) Using PIPE (preferable to using intermediate files), pass the above cmd to ANA/SYS then scan the output to extract the field of interest.

Can anyone point me to examples of scripting ANA/SYS?

Thanks
11 REPLIES
Karl Rohwedder
Honored Contributor
Solution

Re: Scripting ANA/SYS

Jack,

do you mean something like:

$ pipe -
write sys$output "tcpip sh dev tna6/full" -
| ana/Sys | search sys$input -
(read sys$input tmp ; ass/job &tmp data)
$ data=f$trnlnm("DATA")
$...

regards Kalle
Karl Rohwedder
Honored Contributor

Re: Scripting ANA/SYS

Oops,
the example misses a vertical bar before the '(read'.

regards Kalle
Hoff
Honored Contributor

Re: Scripting ANA/SYS

What data might you be looking for within the TNA6: UCB and related structures? If it's what I think you're looking for, I think somebody already wrote a tool to pull the port details out more directly -- dig around for telnet and accpornam out in c.o.v. or such.

Jack Trachtman
Super Advisor

Re: Scripting ANA/SYS

Karl,

I know it was misleading, but the TCPIP cmd I gave as an example is an actual ANA/SYS subcmd (try it!).

Hoff,

It's long story, but in short: the F$GETDVI("TT:", "TT_ACCPORNAM") does return the remote host's IP address and the remote host's IP port #, BUT if the remote host is a VMS host, the port # field is replaced by something called "Location", and I want the port #.

Using ANA/SYS w/the example cmd I gave returns the port #. I've tried various cmds to get that port #, and ANA/SYS w/the TCPIP cmd seems the best I can find. If I had some Macro or other language skills, I might try to poke into the system, but I don't have that expertise, so I'm trying to figure out some way to use ANA/SYS within a PIPE (because I hate creating temp files!).
John Gillings
Honored Contributor

Re: Scripting ANA/SYS

Jack,

Kalle's example (with correction) works for me. Complete example (assuming you want your own terminal):

$ PIPE WRITE SYS$OUTPUT -
"tcpip show device/full ",F$TRNLNM("TT")-"_" |-
ANALYZE/SYSTEM |-
SEARCH sys$pipe "Port:" | -
(READ sys$pipe p ; -
p=F$ELEMENT(3,":",p) ; -
DEFINE/JOB/NOLOG port &p)
$ SHOW LOG/JOB port

For a more general mechanism for scripting variable input into programs, complex sequences of commands, either place multiple "WRITE SYS$OUTPUT" commands within brackets in the first pipe stage, or execute another command procedure to generate the output lines. (I tend to recurse into myself with p1 as a tag to avoid multiple files). Example for this problem:

$ IF F$EXTRACT(0,5,p1).EQS."STAGE" THEN GOTO 'p1'
$ self=F$PARSE(";",F$ENVIRONMENT("PROCEDURE"))
$ PIPE @'self' STAGE1 |-
@'self' STAGE2 |-
@'self' STAGE3 |-
@'self' STAGE4
$ EXIT
$
$ STAGE1:
$ WRITE SYS$OUTPUT "tcpip show device/full "+F$GETDVI(F$TRNLNM("TT"),"DEVNAM")-"_"
$ EXIT
$
$ STAGE2:
$ DEFINE/USER SYS$INPUT SYS$PIPE:
$ ANALYZE/SYSTEM
$ EXIT
$
$ STAGE3:
$ SEARCH SYS$PIPE: "Port:"
$ EXIT
$
$ STAGE4:
$ READ SYS$PIPE p
$ p=F$ELEMENT(3,":",p)
$ DEFINE/JOB/NOLOG port 'p'
$ EXIT

Notes:

For this case, there are some peculiarities in device and logical names which require F$GETDVI to be used in this context to determine the terminal name, but not from the command line. The leading "_" also needs to be stripped for the SDA extension to recognise the device.

In general, only the complex cases need the self recursion. One liners can be coded directly into the PIPE command.

Testing can be done from the command line by invoking the stages explicitly:

$ PIPE @proc STAGE1 | @proc STAGE2

etc...

It also sometimes makes sense to parameterise the input pipe:

$ PIPE ...
@'self' STAGE3 SYS$PIPE: "Port:" | -
etc...


$ STAGE3:
$ SEARCH 'p2' "''p3'"

This means the stages can be used to process files, as well as piped input. Thus:

$ PIPE @proc STAGE1 | @proc STAGE2 > check.tmp

$ @proc STAGE3 check.tmp "Port:"

A crucible of informative mistakes
Jack Trachtman
Super Advisor

Re: Scripting ANA/SYS

John,

Thanks much for the long answer - it will take me a while to digest all the info!

I tried your example pertinant to my question, and it worked, but...

I now have a question about SDA. I have reduced your script to show the problem:

$ PIPE WRITE SYS$OUTPUT -
"tcpip show device/full ",F$TRNLNM("TT")-"_" |-
ANALYZE/SYSTEM

When I run this I get:

$ PIPE WRITE SYS$OUTPUT -
"tcpip show device/full ",F$TRNLNM("TT")-"_" |-
ANALYZE/SYSTEM

OpenVMS (TM) system analyzer

%TCPIP-I-LINKDATE, TCPIP$TNDRIVER linked on 20-APR-2006 18:22:33.17
%TCPIP-I-LINKDATE, TCPIP$BGDRIVER linked on 24-JUL-2006 15:40:09.29
%TCPIP-I-LINKDATE, TCPIP$PROXY_SERVICES linked on 18-SEP-2003 22:00:28.99
%TCPIP-I-LINKDATE, TCPIP$INTERNET_SERVICES linked on 24-JUL-2006 15:40:15.52
%TCPIP-I-VERSION, TCP/IP Services for OpenVMS Version 4196548608.0
-TCPIP-W-JUSTINCASE, In case you're curious, this is NOT a valid version of TCPI
P
-TCPIP-W-DISCLAIMER, You are proceeding at your own risk!
%TCPIP-W-NOREAD, unable to access location FFFFFFFF.B4DE0168
%TCPIP-I-LASTSTART, Driver last started 17-NOV-1858 00:00:00.45
-TCPIP-I-STARTCOUNT, Driver was started 1 time
-TCPIP-I-PREVSTART, Previously started at 7-JUN-2007 20:51:34.25
%TCPIP-W-NOREAD, unable to access location FFFFFFFF.B4DE0264
%TCPIP-I-TRACEINFO, Trace information is not available
%TCPIP-E-NOPWIP, Pathworks-over-IP (PWIP) driver is not present
%TCPIP-E-NONFSSVCS, NFS Services execlet is not present
%TCPIP-E-NOTBGDEVICE, Not a BG (INET network socket) device
-TCPIP-E-NOTTNDEVICE, Not a TN (network terminal) device
$ exit


If I run SDA interactively and type in the "TCPIP..." cmd, I first get the above display with a "Press RETURN to continue". Pressing RETURN gets the screen with the info I need, but yur script causes SDA to exit at the "Press..." prompt.

Just what is SDA doing here & how do I suppress this first screen?

Thanks
Jack Trachtman
Super Advisor

Re: Scripting ANA/SYS

John,

Just talked to HP and what I'm seeing is info about the TCPIP subsystem which gets loaded and displayed the first time the cmd is used.

Any thoughts on how to modify your script to work around this?

Thanks again
John Gillings
Honored Contributor

Re: Scripting ANA/SYS

Jack,

> Any thoughts on how to modify
>your script to work around this?

First fix would be to fix the TCPIP mismatch.

Since I don't see that error, I can't test, but if all you need is a "Press return to continue" you should be able to get around that with:

$ PIPE (WRITE SYS$OUTPUT "" ; -
WRITE SYS$OUTPUT -
"tcpip show device/full ",F$TRNLNM("TT")-"_" ; WRITE SYS$OUTPUT "") |-
ANALYZE/SYSTEM

The additional CRs should be benign for systems that don't have the TCPIP mismatch, and if you filter the output with SEARCH you should be able to skip all the warnings.

That said, you really should be fixing the underlying mismatch.
A crucible of informative mistakes
Jack Trachtman
Super Advisor

Re: Scripting ANA/SYS

John,

Sorry to keep dragging this on...

If I copy the cmd shown in your last email, and paste it into a Telnet session, it works.

If I put your cmd into a script and run it, ANA/SYS exits where it comes to the first prompt of Press RETURN to continue.

Any suggestions?
Jim_McKinney
Honored Contributor

Re: Scripting ANA/SYS

Since you're doing this interactively SDA tries to help you out. It determines the page length of your terminal (likely 24) and then pauses to give you a chance to read the display of that many lines and wants you to press return to continue on. You should be able to just insert a "set term/page=255" at the beginning of your piped commands and a "set term/page=24" at the end. Not particularly elegant but it should suffice if your goal is to do this in a single command line.
Jack Trachtman
Super Advisor

Re: Scripting ANA/SYS

Thanks all.

I've now got some useful ideas.