|
Example-PLI How To Delete a Logical name from a Logical Name Table, Pass and Parse Arguments From The Command Line
Copyright (c) Kednos Corporation 2007. All rights reserved
LAYERED PRODUCT: Alpha PLI, V4.5 OP/SYS: VMS, V8.3
SOURCE: Kednos Customer Support Center
OVERVIEW:
This program demonstrates how to pass information from the command line
to a PLI program using the Run-Time Library routine LIB$GET_FOREIGN and
how to parse the arguments from the command line using the VERIFY and SEARCH
builtin fuctions with and/or as separators.
How to call SYS$DELLNM to delete a logical name from a table
*** CAUTION ***
This sample program has been tested using Alpha PLI V4.5 on OpenVMS V8.3. However,
we cannot guarantee its effectiveness because of the possibility of error
in transmitting or implementing it. It is meant to be used as a template
for writing your own program and it may require modification for use on your
system.
PROGRAM NOTES:
This program may be executed in one of 2 ways:
1) Run DELLNM.EXE
At the prompt, enter the information.
2) Set up a symbol as follows:
DELLNM="$DISK:[DIRECTORY]DELLNM.EXE"
Invoke the program and enter the command line data
DELLNM logical-name logical-name-table acmode
Here is an example
$ define test abc
$ sho log test
"TEST" = "ABC" (LNM$PROCESS_TABLE)
$ dellnm="$disk$common:[work]dellnm.exe"
$ dellnm test LNM$PROCESS_TABLE 2
SS$_NORMAL
$ sho log test
%SHOW-S-NOTRAN, no translation for logical name TEST
PROGRAM:
By uncommenting the PUT statements you can see what happens at each step
of the program.
/* COPYRIGHT (C) 2007 BY
** KEDNOS CORPORATION, PEBBLE BEACH.
** ALL RIGHTS RESERVED.
**
** THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
** ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE INCLUSION
** OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER COPIES
** THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER
** PERSON. NO TITLE TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY TRANSFERRED.
**
** THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
** SHOULD NOT BE CONSTRUED AS A COMMITMENT BY KEDNOS CORPORATION.
**
** KEDNOS ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS
** SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY KEDNOS.
**
** NO RESPONSIBILITY IS ASSUMED FOR THE USE OR RELIABILITY OF SOFTWARE
** ON EQUIPMENT THAT IS NOT SUPPLIED BY KEDNOS CORPORATION.
**
** SUPPORT FOR THIS SOFTWARE IS NOT COVERED UNDER ANY KEDNOS SOFTWARE
** PRODUCT SUPPORT CONTRACT, BUT MAY BE PROVIDED UNDER THE TERMS OF THE
** CONSULTING AGREEMENT UNDER WHICH THIS SOFTWARE WAS DEVELOPED.
*/
dellnm: proc options(main,ident('V1.0'));
%include SYS$DELLNM;
%include $ssdef;
%include $stsdef;
%include $rmsdef;
%include lib$get_foreign;
%include lib$get_symbol;
dcl LogicalName char(80);
dcl command_line char(80) varying;
dcl prompt_flag bit(32) aligned init('0'b);
dcl (i,j,t) fixed bin(31);
dcl nametab char(70);
dcl nametab1 char(24) static initial('HBMM$DEVICE_POLICY_TABLE');
dcl processdir char(20) static initial('LNM$SYSTEM_DIRECTORY');
dcl priv char(6) static initial('SYSNAM');
dcl status fixed bin(31);
ON error snap system;
Again:
sts$value = lib$get_foreign(command_line, 'Enter Logical Name: ',,prompt_flag);
if ^sts$success
then signal vaxcondition(sts$value);
command_line = ltrim(command_line, ' '); /* string is space followed by TAB
/* if you wanted / as a separator
then the string would be '/' */
/* put skip list('Command ',command_line);*/
i = search(command_line,' ');
/* put skip list('i = ',i); */
LogicalName = substr(command_line,1,i-1);
nametab = rtrim(ltrim(substr(command_line,i+1),' '));
j = search(nametab,' ');
/* put skip list('j = ',j); */
t = verify(nametab,' ',j+1); /* see if acmode follows */
if t > 0 then /* acmode follows */ acmode = binary(substr(nametab,t,1),7);
/* put skip list('acmode = ', acmode);
Put skip list ( 'Name Table entered: ', nametab); /* debug */
if nametab = '' then nametab = nametab1;
/* Put skip list ( 'length(LogicalName) = ', length(LogicalName)); /* debug */
/* Put skip list ( 'Logical Name entered: ', LogicalName); /* debug */
dcl acmode fixed bin(7) init(0);
/*********
KERNEL 0 (requires SYSNAM priviledge to be enabled)
EXEC 1
SUPER 2
USER 3
*********/
status = SYS$DELLNM(descriptor(substr(nametab,1,j-1)), descriptor(substr(LogicalName,1,i-1)), acmode );
select (status);
when(SS$_NORMAL) do;
/* The service completed successfully.*/
put skip list('SS$_NORMAL');
end;
when(SS$_ACCVIO) do;
/* The service cannot access the locations specified by
one or more arguments.*/
put skip list('SS$_ACCVIO');
end;
when(SS$_BADPARAM) do;
/* One or more arguments have an invalid value, or a logical
name table name was not specified.*/
put skip list('SS$_BADPARAM');
end;
when(SS$_INSFMEM) do;
/* There is insufficient dynamic memory to build a message
describing the deletion of a clusterwide name.*/
put skip list('SS$_INSFMEM');
end;
when(SS$_IVLOGNAM) do;
/* The lognam argument specifies a string whose length is not
in the required range of 1 through 255 characters.*/
put skip list('SS$_IVLOGNAM');
end;
when(SS$_IVLOGTAB) do;
/* The tabnam argument does not specify a logical name table.*/
put skip list('SS$_IVLOGTAB');
end;
when(SS$_NOLOGNAM) do;
/* The specified logical name table does not exist,
or a logical name with an access mode equal to or less
privileged than the caller's access mode does not exist
in the logical name table.*/
put skip list('SS$_NOLOGNAM');
end;
when(SS$_NOLOGTAB) do;
/* The specified logical name table does not exist.*/
put skip list('SS$_NOLOGTAB');
end;
when(SS$_NOPRIV)
do;
/* The caller lacks the necessary privilege to delete the logical name.*/
put skip list('SS$_NOPRIV');
end;
when(SS$_TOOMANYLNAM) do;
/* The logical name translation of the table name exceeded
the allowable depth (10 translations).*/
put skip list('SS$_TOOMANYLNAM');
end;
otherwise do;
end;
end /* select */;
end dellnm;
Last updated 10-SEP-2007
and Web-enabled with
|
| |
| |