TSO NETSTAT STACK – doesn’t. Get fullscreen output instead.

I was getting annoyed because the TCPIP NETSTAT command displays the output in line mode, and you cannot scroll back to look at it.

The documentation says you can use NETSTAT … STACK in a Rexx program, and use queued() to see how many lines were on the stack. This did not work for me. I always got 0 lines on the stack, until I exited ISPF when they all tried to execute and produced “IKJ56621I INVALID COMMAND NAME SYNTAX”.

A better (and more efficient way – you have to write less code) is create an Rexx program. I used USER.Z24C.CLIST(NS)

/* REXX */ 
ADDRESS ISPEXEC
'ISREDIT MACRO (a)' 
x = outtrap("var.") 
if a   = "" then a   = "HOME" 
address TSO "netstat "a 
x = outtrap("OFF") 
if var.0  = 0 then exit 

"ISREDIT AUTOSAVE OFF PROMPT" 
do y =1 to var.0 
   fn= var.y 
   "ISREDIT LINE_AFTER  .ZLAST     =  (fn)" 
end 

If you use this command within an ISPF edit session, it will append the output to the bottom of the file.

Note: You pass parameters via ISREDIT MACRO(parms) rather than pars args parms.

You can always use DELETE ALL NX to clear the file before running the exec.

It uses AUTOSAVE OFF PROMPT, to make you explicitly save the output – or cancel from the session, and do not accidentally save it.

Extend it

As the output is in an ISPF Editor session, you can write edit macros to process the content, and filter or reformat it.

Shorthand

I extended it so I say “ns h” and it issues the netstat home command etc.

For example

'ISREDIT MACRO (a)' 
if a   = "" then a  = "HOME" 
else 
if a = "i" then a = "devlinks (intfname ifportcp6" 
else 
if a = "h" then a = "home" 
else 
if a = "r" then a = "route addrtype  IPV6" 
else 
if a = "n" then a = "nd" 
address TSO "netstat "a 

2 thoughts on “TSO NETSTAT STACK – doesn’t. Get fullscreen output instead.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s