Operating System - OpenVMS
1822959 Members
3691 Online
109645 Solutions
New Discussion юеВ

Re: dcl / lexical functions / python

 
John Tannahill
Frequent Advisor

dcl / lexical functions / python

If I interactively execute:
sh log sys$output
I get:
"SYS$OUTPUT" = "_RIPPLE$FTA40:" (LNM$PROCESS_TABLE)

Likewise if I execute:
output = f$trnlmn("sys$output")
write sys$output "''output'"
I get:
_RIPPLE$FTA40:

I would like to create a Python interface to f$trnlmn.

If I do:
pipe = os.popen('f$trnlmn("sys$output")')
output = pipe.read()
err = pipe.close
sys.stdout.write(output)

I get (as expected):
%DCL-W-IVERB, unrecognized command verb - check validity and spelling
\F$TRNLMN\

If I do:
pipe = os.popen('output = f$trnlmn("sys$output)')

It runs, but I don't know how to get the contents of 'output' back into the Python process?

Suggestions?

Thanks,
John


8 REPLIES 8
Steven Schweda
Honored Contributor

Re: dcl / lexical functions / python

'write sys$output f$trnlnm("sys$output")' in
the os.popen()?

> %DCL-W-IVERB [...]

F$TRNLNM is not a command. WRITE is.

Note that it _is_ F$TRNLNM, not F$TRNLMN.
(TRaNslate Logical MiNnesota?)
John Tannahill
Frequent Advisor

Re: dcl / lexical functions / python

Steven,

That's why the error was "expected".

Sorry about the typo, everything else still holds.

Still need to be able to get the contents of 'output' back into the Python process.

John
Steven Schweda
Honored Contributor

Re: dcl / lexical functions / python

> 'write sys$output f$trnlnm("sys$output")' in
> the os.popen()?

Did you try this instead?
Hein van den Heuvel
Honored Contributor

Re: dcl / lexical functions / python

John,

Seems to me you are entirely on the wrong track here!

I thought you wanted to get away from DCL?
[ http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1159356 ]

The F$stuff is strictly and only DCL and requires a process running DCL for you. Yuck!

The F$Stuff is 99% directly built on real system services like SYS$TRNLNM.

Just judging by the examples in the Jean-Francois' OpenVMS article those system services as nicely, directly, available in Python... so cut out the middle man (DCL).
See: http://h71000.www7.hp.com/openvms/journal/v6/python-openvms-jfp.html

But what is worse... if you open a process, you'll talk to it via a pipe and the sys$output logical name for that process will not be same as the one you are trying to look up. It will point to a pipe (mailbox), not a terminal.

You may want to check out 'get_logical' in the Python Reference manual:

http://vmspython.dyndns.org/docs/python_vms/installation_manual.html

dig dig dig dig

Cheers,
Hein.

John Tannahill
Frequent Advisor

Re: dcl / lexical functions / python

Steven,

Your suggestion worked. Pretty straightforward, just didn't think of it.

Thanks,
John
John Tannahill
Frequent Advisor

Re: dcl / lexical functions / python

Hein,

Never fear, in the end the DCL will be gone, but it will be a while. Just taking baby steps right now. Trying to understand things, etc. I have no prior knowledge of the DCL code.

Thanks for your suggestions,
John
John Tannahill
Frequent Advisor

Re: dcl / lexical functions / python

pipe = os.popen('write sys$output f$trnlnm("sys$output")') worked.

Thanks,
John
Jean-Fran├зois Pi├йronne
Trusted Contributor

Re: dcl / lexical functions / python

John,

import vms.rtl.lib
vms.rtl.lib.get_logical('SYS$OUTPUT')

or

import os
os.getenv('SYS$OUTPUT')

will do the job,

lib$get_logical puts something in the first 4 characters and then puts the logical translation, it's not a Python bug...

getenv has not the problem.


JF