Solved

Script in OPEN VMS to kill sessions

Posted on 2009-04-02
12
1,607 Views
Last Modified: 2013-12-21
Hi I am looking to create a script in OPENVMS, ujuu. To kill the session of one user from one computer.
To see the users I use this command

$ sh user/full
      OpenVMS User Processes at  2-APR-2009 11:18:25.67
    Total number of users = 1,  number of processes = 1

 Username Process Name    PID     Terminal
 SYSTEM   SYSTEM        000038B6  TNA1015: (Host: 14.25.101.43     Port: 1980 )
 SYSTEM   SYSTEM        000037B6  TNA1015: (Host: 14.25.102.53     Port: 1980 )
 SYSTEM   SYSTEM        000036B6  TNA1015: (Host: 14.25.101.43     Port: 1980 )
 SYSTEM   SYSTEM        000035B6  TNA1015: (Host: 14.25.102.53     Port: 1980 )

$

Now I want to take the PID that user connected from one HOST. Example only that 14.25.102.53.

any idea, in UNIX I can use grep, but it doesn't exist

Thanks
Edu
0
Comment
Question by:ealcaniz
  • 7
  • 4
12 Comments
 
LVL 10

Expert Comment

by:3_S
Comment Utility
Hi,

The VMS equivalent of grep is the command search.
I guess you are trying to place the output of  sh user/full to a file and then kill all processes? Is this correct?
0
 
LVL 3

Author Comment

by:ealcaniz
Comment Utility
Yes I want to kill the process of one host. I will see search
0
 
LVL 3

Author Comment

by:ealcaniz
Comment Utility
I can get the lines

pipe sh users/full | search SYS$INPUT "10.1.1.1"

but how I can get only the column of PID?

0
 
LVL 7

Expert Comment

by:dolomiti
Comment Utility
hi,
all systems have in the order:
kernel,
api,
commands (prebuilt programs written in C, in Usnix in MacroAssembler or C for VMS that uses api)
shell (DCL in VMS)

You can use scripts (DCL commands in VMS) that use commands and DCL primitive (IF,GOTO,SUB)
You can write program using C and call SystemServices and/or RunTimeLibrary

Shell in VMS is not powerfull as in Unix, but VMS has a level that in Unix you don'find:
here they are called Lexicla Function.
I unix the approach is different: the output command are straight and using commands as
grep, ! (pipe), awk,... you can with elegance, build a thing in 10 different way.

In VMS the way is more direct and often unic: to kill a process or you know the id or you have to list all.
To do this you have to call (iteretively) the system service $GETPRJ, you can write a compiled program,
(hard) or you can use Lex: more or less, exist a Lex for each important System Service.
During the loop, you can know exact info (by other LEx) about process.
Between these you find host,username,type of process (batch,interactive,network) and PID.
When you find the one you want, kill it using STOP/id...
This is the way.
Today I am not able to give you an example or the script.
But if you like to discover them by yourself this may be enough.
Next days, I can be able to retrive commands to do it.

bye
vic
0
 
LVL 3

Author Comment

by:ealcaniz
Comment Utility
Thanks vic, it will be wonderfull if you should find the commands, because I am reading and reading with DCL and Lex, .. if very very messy. Like you said before UNIX is more elegant.
0
 
LVL 3

Author Comment

by:ealcaniz
Comment Utility
Please any example.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 7

Accepted Solution

by:
dolomiti earned 500 total points
Comment Utility
hi ealcaniz,
sorry for late, but probably good news.
Warning to the space after ipaddress "192.168.5.132 ", between 2 and "

some rows are unnecessary, but I leave them for other cases.
I have not deeply tested, call it beta release!

bye
vic
$ context = ""

$ start:

$   pid = F$PID(context)

$   IF pid .EQS. "" THEN EXIT

$   Mode =      F$GETJPI( pid, "MODE" )

$   IF Mode .NES. "INTERACTIVE" THEN GOTO START

$   Utente    = F$GETJPI( pid, "USERNAME" )

$   Terminale = F$GETJPI( pid, "TERMINAL" )

$   x =         F$GETJPI( pid, "TT_PHYDEVNAM" )

$   PortNam =   F$GETJPI( pid, "TT_ACCPORNAM" )

$   SHOW SYMBOL pid

$   SHOW SYMBOL Utente

$   SHOW SYMBOL Terminale

$   SHOW SYMBOL x

$   SHOW SYMBOL PortNam

$   SHOW SYMBOL Mode

$   Len = F$LENGTH(PortNam)

$   Pos = F$LOCATE( "192.168.5.132 ", PortNam )

$   IF Pos .LT. Len THEN WRITE SYS$OUTPUT ">>>>>>>>>>>>>>>>>>>>>> Bingo"

$   IF Pos .LT. Len THEN STOP /IDENTIFICATION='pid'

$   WRITE SYS$OUTPUT "----------------------------------"

$   GOTO start

Open in new window

0
 
LVL 3

Author Comment

by:ealcaniz
Comment Utility
Thanks a million. I am tested for myself, Give me a error

$ start:
%DCL-W-NOLBLS, label ignored - use only within command procedures
 \START:\

For this thing I think is not working the loop. Only give blank in the symbol.

0
 
LVL 3

Author Comment

by:ealcaniz
Comment Utility
OK. solve this thing it was to put in UpperCase, but When I run the program doesn't give me information


SHOW SYMBOL Utente
  SHOW SYMBOL Terminale
  SHOW SYMBOL x
  SHOW SYMBOL PortNam
  SHOW SYMBOL Mode


PortNam and the rest is blank.  
0
 
LVL 7

Expert Comment

by:dolomiti
Comment Utility
hi ealcaniz,
sorry if I have not been clear:
what I sent you is a script:
create a file (by edit/etd or edit/tpu) ie named KILLER.COM and write inside what I sent you
save it

at DCL level (system user right) enter

@KILLER

for first time launch it as is without change ip address: you will see a list of interactive process.
if it run, put a right address.

bye
vic
0
 
LVL 7

Expert Comment

by:dolomiti
Comment Utility
hi ealcaniz,

any news about script ?

bye
vic
0
 
LVL 3

Author Comment

by:ealcaniz
Comment Utility
Sorry delay but it's working successfully only I have to use nameserver instead IP
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now