(PYVMS LOGO) Python on OpenVMS

(go to: table of contents, index, list of pyvms, prev: CRTL_FROM_VMS, next: CRTL_TO_VMS)


CRTL_OPEN - call C RTL open() routine


Calls the C RTL open() routine. This is similar to the posix.open() routine, but it allows to specify a fourth argument.

Note: the creat() and open() routine in the C RTL expect an optional argument list. The Python interface requires that you specify all the arguments as a single tuple that is passed as argument 4 - see the examples section below.

Format:

    fd = pyvms.crtl_open (filename, flag [,mode] [,RMS-arguments])
Returns:
fd
file descriptor
Use the routines in the 'posix' module to work with it.
Arguments:
filename
name of the file to open
flag
flags like O_WRONLY or O_CREAT
mode
file-protection mode. Use None or 0777 (that's octal!) to use VMS' default mechanism.
RMS-arguments
This is a tuple of strings to control the file attributes. See the examples section below.

Do not use the "acc" or "err" keywords! The interface does neither support these callback routines nor prevent use of them!

Examples:

>>> import pyvms

>>> O_WRONLY =   001
>>> O_CREAT  = 01000
>>> #          ^--------- these are OCTAL values !
>>> flags = O_WRONLY + O_CREAT


>>> fd = pyvms.crtl_open \
...      ('CRTL_OPEN.TMP'                 # filename
...      ,flags                           # flag
...      ,None                            # mode
...      ,("alq=200","rat=ftn","rfm=stm") # RMS-arguments
...      )
>>> import posix
>>> posix.write (fd, ' Hello!')
7                                         # number of bytes written
>>> posix.close (fd)
>>>

$ directory/full CRTL_OPEN.TMP

Directory DKA100:[PYTHON.PYTHON-1_5_1.VMS]

CRTL_OPEN.TMP;1               File ID:  (12140,33,0)
Size:            1/200        Owner:    [G1,SYSTEM]
Created:   31-DEC-1998 18:30:45.28
Revised:   31-DEC-1998 18:31:30.14 (1)
Expires:   <None specified>
Backup:    <No backup recorded>
Effective: <None specified>
Recording: <None specified>
File organization:  Sequential
Shelved state:      Online
File attributes:    Allocation: 200, Extend: 0, Global buffer count: 0
                    No version limit
Record format:      Stream, maximum 8 bytes
Record attributes:  Fortran carriage control
RMS attributes:     None
Journaling enabled: None
File protection:    System:RWED, Owner:RWED, Group:RE, World:
Access Cntrl List:  None

Total of 1 file, 1/200 blocks.
$


----------

>>> flags = 0
>>> fd = pyvms.crtl_open \
...      ('%CRTL_OPEN.TMP'                # *BAD* filename
...      ,flags                           # flag
...      ,None                            # mode
...      ,("alq=200","rat=ftn","rfm=stm") # RMS-arguments
...      )
Traceback (innermost last):
  File "<stdin>", line 1, in ?
pyvms.error: (100164, '%RMS-F-WLD, invalid wildcard operation')
>>>


----------
$!+
$! Create a simple test queue to demonstrate spool-on-close.
$! Need to point SYS$PRINT to this queue.
$!-
$ initialize /queue /device /noSTART PY_SPL_TEST
$ define SYS$PRINT PY_SPL_TEST

$ python
[...]
>>> import pyvms

>>> O_WRONLY =   001
>>> O_CREAT  = 01000
>>> #          ^--------- these are OCTAL values !
>>> flags = O_WRONLY + O_CREAT

>>> fd = pyvms.crtl_open \
...      ('SPOOL.TMP'                     # filename
...      ,flags                           # flag
...      ,None                            # mode
...      ,("fop=spl",)                    # RMS-arguments
...      )        # ^- need a tuple, here !  
>>> import posix
>>> posix.write (fd, ' Hello!')
7                                         # number of bytes written
>>> posix.close (fd)
>>>

$ show queue /full /all PY_SPL_TEST
Printer queue PY_SPL_TEST, stopped, mounted form DEFAULT
 /BASE_PRIORITY=4 /DEFAULT=(FEED,FORM=DEFAULT) /OWNER=[G1,SYSTEM]
 /PROTECTION=(S:M,O:D,G:R,W:S)

 Entry  Jobname         Username     Blocks  Status
 -----  -------         --------     ------  ------
    23  SPOOL           ZESSIN            1  Pending (queue stopped)
        Submitted 12-MAR-1999 14:09 /FORM=DEFAULT /PRIORITY=100
        File: _$99$DKA100:[PYTHON.PYTHON-1_5_1.VMS]SPOOL.TMP;1
$
$! -- cleanup
$ deassign SYS$PRINT
$ delete /queue PY_SPL_TEST
$ delete SPOOL.TMP;1
$

(go to: table of contents, index, list of pyvms, prev: CRTL_FROM_VMS, next: CRTL_TO_VMS)

12-MAR-1999 ZE.