Operating System - OpenVMS
1827808 Members
2330 Online
109969 Solutions
New Discussion

Re: SET HOST /LOG logfile

 
Michael Moroney
Frequent Advisor

SET HOST /LOG logfile

Quick question: Is there an equivalent to SET HOST 0/LOG=whatever.log that allows someone to examine "whatever.log" by typing it while the SET HOST session is still active? Also, is there any way for an application to get a logged terminal session by assigning a channel to a terminal and doing $QIOs to it. This is similar to SET HOST/LOG but initiated differently.
14 REPLIES 14
Hoff
Honored Contributor

Re: SET HOST /LOG logfile

1: Probably easier to use a client-side widget such as the screen utility or VCS. Alternatively, there are widgets such as peek and spy that can probably be pressed into service.

2: Your host I/O is aimed away from the host and toward the terminal, and not in toward the host from the terminal. Which means something akin to a pseudo-terminal would be one way to do this.

Poke around and there are some other screen-scraping tools around.

I recall that somebody posted one such tool in response to an other recent thread; I'd suggested pseudo-terminals in that thread, so you have a search target.



Hein van den Heuvel
Honored Contributor

Re: SET HOST /LOG logfile

I suspect you would have to roll your own using the Psuedo Terminal Driver.
A good starting point would be: SYS$COMMON:[SYSHLP.EXAMPLES]ALPHA_LOGGER.C
There may well be others out there.

SET HOST/LOG is RTPAD opening a log file non-shared. No RMS locks to poke to get it to flush, just a file system lock.
For RMS it uses the default settings which are often 16KB buffers, and it does not have a (timer based) flush. So the process might never write to disk untill the end.

So if you know you want to 'see' the data on the disk, then you may want to issue SET RMS/BLOCK=1. This will force an IO for every 512 bytes of data. You can then uses DUMP (in a round-about-way to find the LBN's) to see the data on the disk.

I own a tool which can 'clone' the locked file into an other file for a sneak peak, but it can only clone what is out there, not what is still in the process memory.

For desperate, or just one-off support inverstigation, cases you could of course also use SDA to directly peak into the process RMS memory.
This is not too too hard.
$ANALYZE/SYSTEM
SDA> SET PROC
SDA> SHOW PROC/RMS=(RAB,BDBSUM)

The RBF/RSZ in the RAB will describe the last record put out there.

The RFA in the RFA will describe the VBN + byte-offset where to expect the last data in the blcok buffer.

The VBN field in the BDBSUM will indicate the block range for the buffer. The ADDR field will point to the data in memory.

SDA>examine ;
... enjoy!


Hope this helps some,
Hein van den Heuvel (at gmail dot com)
HvdH Performance Consulting



Michael Moroney
Frequent Advisor

Re: SET HOST /LOG logfile

Thanks. This will be for an ongoing need, so I need more than SDA. Pseudoterminals appear to be what I need, and some searching has revealed some code that can be adapted, and it has the icky pseudoterminal portion of the code already written.

What I will come up with is something that sits between a pseudoterminal and a (real) terminal that acts very much like SET HOST/LOG 0, except the log file will be sharable, it will work both ways (that is, one can open a channel to the FTAx: device and data written to it will be logged as well as being able to "log in" on the FTAx: pseudoterm), and, of course, no need for network stuff. Hein's SET RMS/BLOCK=1 may be a stopgap if CONVERT/SHARE or BACKUP/IGNORE=INTERLOCK can read the SET HOST log file.
Hein van den Heuvel
Honored Contributor

Re: SET HOST /LOG logfile

>> if CONVERT/SHARE or BACKUP/IGNORE=INTERLOCK can read the SET HOST log file.

Sorry, no go.
CONVERT will refuse to open the file.
BACKUP will honor the EOF mark, which is at 0.
BACKUP badly needs an /IGNORE=EOF, but suggestions to that extent have not been folowed up. I'll Email you something, but O do not want to send it to 'the world' (that's a joke just for Mike).

Hein.




John Gillings
Honored Contributor

Re: SET HOST /LOG logfile

Michael,

First question, yes, there is a way, but it's a bit klunky - use process permanent files.

$ OPEN/WRITE/SHARE mylog whatever.log
$ SET HOST 0/LOG=mylog

Output from the session is now written to the log file "whatever.log" as shared access.

As Hein says, the EOF won't be updated unless necessary, so TYPE or even CONVERT/SHARE don't help, BUT you can update the EOF with the sequence:

$ OPEN/APPEND/SHARE tmp whatever.log
$ CLOSE tmp

from any process with appropriate access to the file. This includes the session being logged. (but it gets a bit confusing if you TYPE the log file - it's also exponential growth, so be careful!).


The EOF is now up to date, and commands like TYPE and SEARCH will work up to that point in time. The EOF will be set at the end of the CLOSE, so if you do it from the session being logged, the CLOSE command will be visible.

Obviously this isn't something you can do after the session has started, and you need a cooperative target.


Second question... you can't capture the activity on a terminal with ordinary $QIOs. Although you can open a channel to a terminal with SHARE privilege, an I/O operation will only go to one destination. So if you read from the terminal, you will "steal" input from the user, preventing it from going to the logged in process.

There are various utilities around for capturing screen sessions. They have names like "SPY" or "WATCH". They do stuff at driver level to intercept I/O. They're also notorious for crashing systems, so be careful. You may find freeware, but I think there are also some commercial offerings.
A crucible of informative mistakes
Wim Van den Wyngaert
Honored Contributor

Re: SET HOST /LOG logfile

Almost 20 years ago there used to be a product called VIDEO. It allowed to log all activity and also to replay it (as if recorded with a video). You could also take control of the terminal. Don't know what if it still exists.

Wim
Wim
Jess Goodman
Esteemed Contributor

Re: SET HOST /LOG logfile

After you have the log file open read-shared using John Gillings' method:

$ OPEN/WRITE/SHARE mylog whatever.log
$ SET HOST 0/LOG=mylog

Then you can use a DCL READ/WRITE loop to "type" out the file without first setting the file's EOF.

Attached is SHARED_TYPE.COM, a DCL procedure I wrote for this purpose almost 20 years ago.
It will type out data from a read-shared file even if the EOF still shows as 0.
I have one, but it's personal.
John Gillings
Honored Contributor

Re: SET HOST /LOG logfile

re: Jess,

>Then you can use a DCL READ/WRITE loop
>to "type" out the file without first
>setting the file's EOF.

That's the slow way! It's sufficient to OPEN/APPEND/SHARE then CLOSE the file.
A crucible of informative mistakes
Hoff
Honored Contributor

Re: SET HOST /LOG logfile

Ten seconds with a hot soldering iron, anyone?

Tapping a serial line is trivial, and monitors are around if you're not inclined to solder your own T.
Michael Moroney
Frequent Advisor

Re: SET HOST /LOG logfile

I tried the OPEN/WRITE/SHARE and OPEN/APPEND/SHARE a PPF and using that as the log before I wrote the first message, and didn't see anything in the file until the SET HOST session ended, in other words, no better than a regular file. I don't know why it didn't work for me.

The customer doesn't care for software needing godlike powers to run, but they do like the pseudoterminal. I didn't think of the RS232 loopback, even though I did that myself once long ago (to copy a file from another system) They have an RS232 adapter with plenty of spare ports. Now off to try to figure out which pins should go where.
John Gillings
Honored Contributor

Re: SET HOST /LOG logfile

Michael,

Sorry, maybe I didn't explain clearly enough. You need to OPEN/APPEND/SHARE then CLOSE the file to bring the EOF up to date AT THE TIME OF THAT CLOSE. It will then stay there until you repeat the OPEN/APPEND/SHARE & CLOSE. There's no way to have it "automatically" update.

Here's a sample transcript - it's V7.3-2 so I'm not depending on anything recent. It's also a bit confusing since the process is looking at its own logfile.

$ open/write/share mylog whatever.log
$ set host 0/log=mylog

Username: jg
Password:

Unauthorized Access Prohibited

Last interactive login on Thursday, 17-JUL-2008 12:02:14.34
Last non-interactive login on Thursday, 17-JUL-2008 05:00:28.90

$ dir/size=all whatever.log

Directory DSA1:[OMEX_SYS_ASX]

WHATEVER.LOG;1 0/37 17-JUL-2008 12:05:12.61

Total of 1 file, 0/37 blocks.
$ type whatever.log
$
! Nothing

$ open/append/share tmp whatever.log
$ close tmp
$ dir/size=all whatever.log

Directory DSA1:[OMEX_SYS_ASX]

WHATEVER.LOG;1 2/37 17-JUL-2008 12:05:12.61

Total of 1 file, 2/37 blocks.
$
! EOF has moved

$ type whatever.log

Username: omex_sys_asx
Password:

Unauthorized Access Prohibited

Last interactive login on Thursday, 17-JUL-2008 12:02:14.34
Last non-interactive login on Thursday, 17-JUL-2008 05:00:28.90

%DCL-S-SPAWNED, process ALIVE_202044A9 spawned
$ dir/size=all whatever.log
Subprocess ALIVE_202044A9 has completed

Directory DSA1:[OMEX_SYS_ASX]

WHATEVER.LOG;1 0/37 17-JUL-2008 12:05:12.61

Total of 1 file, 0/37 blocks.
$ type whatever.log
$ open/append/share tmp whatever.log
$ close tmp

! File is now up to the point of the CLOSE

$ logout
JG logged out at 17-JUL-2008 12:07:50.11
%REM-S-END, control returned to node LOCAL:.JG000::
$
$ type mylog
$
! Nothing visible via the PPF
$
$ type whatever.log

Username: omex_sys_asx
Password:

Unauthorized Access Prohibited

Last interactive login on Thursday, 17-JUL-2008 12:02:14.34
Last non-interactive login on Thursday, 17-JUL-2008 05:00:28.90

%DCL-S-SPAWNED, process ALIVE_202044A9 spawned
$ dir/size=all whatever.log
Subprocess ALIVE_202044A9 has completed

Directory DSA1:[OMEX_SYS_ASX]

WHATEVER.LOG;1 0/37 17-JUL-2008 12:05:12.61

Total of 1 file, 0/37 blocks.
$ type whatever.log
$ open/append/share tmp whatever.log
$ close tmp

! But via the file name, the EOF is up to the last CLOSE

$ OPEN/APPEND/SHARE tmp whatever.log
$ CLOSE tmp

! Reset EOF to current location

$ type whatever.log
Username: jg
Password:

Unauthorized Access Prohibited

Last interactive login on Thursday, 17-JUL-2008 12:02:14.34
Last non-interactive login on Thursday, 17-JUL-2008 05:00:28.90

$ dir/size=all whatever.log

Directory DSA1:[OMEX_SYS_ASX]

WHATEVER.LOG;1 0/37 17-JUL-2008 12:05:12.61

Total of 1 file, 0/37 blocks.
$ type whatever.log
$ open/append/share tmp whatever.log
$ close tmp
$ dir/size=all whatever.log

Directory DSA1:[OMEX_SYS_ASX]

WHATEVER.LOG;1 2/37 17-JUL-2008 12:05:12.61

Total of 1 file, 2/37 blocks.
$
$ type whatever.log

Username: jg
Password:

Unauthorized Access Prohibited

Last interactive login on Thursday, 17-JUL-2008 12:02:14.34
Last non-interactive login on Thursday, 17-JUL-2008 05:00:28.90

?$ dir/size=all whatever.log?

Directory DSA1:[OMEX_SYS_ASX]
WHATEVER.LOG;1 0/37 17-JUL-2008 12:05:12.61

Total of 1 file, 0/37 blocks.
$ type whatever.log
$ open/append/share tmp whatever.log
$ close tmp
$ dir/size=all whatever.log

Directory DSA1:[OMEX_SYS_ASX]

WHATEVER.LOG;1 2/37 17-JUL-2008 12:05:12.61

Total of 1 file, 2/37 blocks.
$
$ type whatever.log

Username: jg
Password:

Unauthorized Access Prohibited

Last interactive login on Thursday, 17-JUL-2008 12:02:14.34
Last non-interactive login on Thursday, 17-JUL-2008 05:00:28.90

$ dir/size=all whatever.log

Directory DSA1:[OMEX_SYS_ASX]

WHATEVER.LOG;1 0/37 17-JUL-2008 12:05:12.61

Total of 1 file, 0/37 blocks.
$ type whatever.log
$ open/append/share tmp whatever.log
$ close tmp
$ logout

JG logged out at 17-JUL-2008 12:07:50.11

$ CLOSE mylog
A crucible of informative mistakes
Michael Moroney
Frequent Advisor

Re: SET HOST /LOG logfile

No, I didn't try that.
Hein van den Heuvel
Honored Contributor

Re: SET HOST /LOG logfile

Nice trick with the shared PPF john!

Here is an other direction for a work-around.
SET HOST /LOG will happily write into a mailbox... which a program, or 'type', can read. See attachment.

I thought It would be enough for a tool to create a mailbox, read and put into a file allowing sharing. However... it seems you still need a home-grown tool, or the OPEN-for-append + close John suggests to get the EOF. Tools like SEARCH and TYPE and CONVERT all use UPI sharing and do not trigger a flush. I guess I'm not smart enough tonite to come up with a standard tool to do this, other than a simple DLC loop as below.

Try it....

$cc mbx
$link mbx
$spawn/nowait run mbx
$set host /log=MBX
blah blah

And in an other session:
$open/read/share=write x 'p1
$loop:
$read/end=done x record
$write sys$output record
$goto loop
$done:
$close x

Or
$ ope/read/appe/share=write x sethost.lis
$ typ sethost.lis
$ close x
$ typ sethost.lis

Hein.
Michael Moroney
Frequent Advisor

Re: SET HOST /LOG logfile

We're going to use a logging program which uses a pseudoterminal to capture the output.

Thanks for all the interesting suggestions.