[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference vmszoo::vms_posix

Title:POSIX for OpenVMS - Public forum
Notice:Internal users of V2.0 please register in note 909
Moderator:STAR::PARKE
Created:Fri Jan 04 1991
Last Modified:Mon Jun 02 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1370
Total number of notes:5127

1366.0. "RMS functionality from POSIX shell" by QCAV01::NRHEGDE (T&E or R&D !?) Fri Apr 04 1997 08:58

Hello !
 We have following setup.
  OpenVMS Alpha V7.1
  POSIX for OpenVMS V3.0

   We have programs using RMS calls. Can anybody tell me how can we
   do RMS calls running from POSIX shell? Is there any way to do it/
   workarounds on this issue?

    Previuos entries does not give any hopes on this.

    Basically it is a porting project from unix to VMS. 
    Since C-ISAM is not available  on OpenVMS we are using RMS.
    

     Thx in advance

     Regards
     Nagaraj Hegde
T.RTitleUserPersonal
Name
DateLines
1366.1STAR::PARKESometimes pigeon, Sometimes statueFri Apr 04 1997 13:204
    You cannot do direct (without POSIX file system intervention) from
    the shell itself.  You can write programs which run under POSIX and
    do OpenVMS System and RMS calls.
    
1366.2example?MUCTEC::BECKERHartmut B., VMS & Languages, MunichMon Apr 07 1997 04:5590
You want an example? Try this.

Hth,
Hartmut

psx> cat x.c
#include        <stdio.h>
#include        <string.h>

#include        <descrip.h>
#include        <psldef.h>
#include        <rms.h>
#include        <secdef.h>
#include        <starlet.h>

int main (void) {

        int     status;
        struct  FAB     fblock;
        char    filename[]= "X.BIN";
        unsigned long inadr[2], retadr[2];
        int     i;
        $DESCRIPTOR (name, "name");

fblock = cc$rms_fab;
fblock.fab$b_acmodes = PSL$C_USER << FAB$V_CHAN_MODE;
fblock.fab$l_fna = filename;
fblock.fab$b_fns = strlen(filename);
fblock.fab$l_fop = FAB$M_UFO;
fblock.fab$b_rtv = 255;
fblock.fab$b_fac = FAB$M_PUT|FAB$M_GET;

status = sys$open (&fblock);
printf ("$open:\t%08x\n", status);
printf ("fab$l_stv:\t%08x\n", fblock.fab$l_stv);

inadr[0] = (unsigned long)inadr;
inadr[1] = (unsigned long)0;
status = sys$crmpsc     (inadr,         /* inadr */
                        retadr,         /* retadr */
                        PSL$C_USER,     /* acmode */
                        SEC$M_WRT|SEC$M_EXPREG|SEC$M_GBL,
                                        /* flags */
                        &name,          /* gsdnam */
                        0,              /* ident */
                        0,              /* relpag */
                        (unsigned short)fblock.fab$l_stv,
                                        /* chan */
                        fblock.fab$w_bls,               /* pagcnt */
                        0,              /* vbn */
                        0,              /* prot */
                        0);             /* pfc */
printf ("$crmpsc:\t%08x\n", status);

printf ("retadr:\t[%08x,%08x]\n", retadr[0], retadr[1]);

/* hack to modify disk file */
scanf ("%d", &i);
*(int *)retadr[0]= i;

status = sys$deltva     (retadr,                /* inadr */
                        0,              /* retadr */
                        0);             /* acmode */
printf ("$deltva:\t%08x\n", status);
status = sys$dassgn ((unsigned short)fblock.fab$l_stv);
printf ("$dassign:\t%08x\n", status);
}

psx> c89 -O x.c
psx> cp a.out x.bin
psx> od x.bin |more
0000000000    000003  000000  000000  000000  001410  000000  000440  000000
0000000020    000150  000000  000230  000000  000270  000000  000000  000000
0000000040    000000  000006  000000  000000  000000  000000  000000  000000
...
psx> a.out
$open:  00010001
fab$l_stv:      000000d0
$crmpsc:        00000619
retadr: [7b038000,7b03a3ff]
255
$deltva:        00000001
$dassign:       00000001
psx> od x.bin |more

0000000000    000377  000000  000000  000000  001410  000000  000440  000000
0000000020    000150  000000  000230  000000  000270  000000  000000  000000
0000000040    000000  000006  000000  000000  000000  000000  000000  000000
...