Solved

Script in OPEN VMS to kill sessions

Posted on 2009-04-02
12
1,637 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
ID: 24049507
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
ID: 24049885
Yes I want to kill the process of one host. I will see search
0
 
LVL 3

Author Comment

by:ealcaniz
ID: 24050072
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 7

Expert Comment

by:dolomiti
ID: 24062926
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
ID: 24062975
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
ID: 24087598
Please any example.
0
 
LVL 7

Accepted Solution

by:
dolomiti earned 500 total points
ID: 24106090
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
ID: 24106960
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
ID: 24107071
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
ID: 24107450
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
ID: 24170630
hi ealcaniz,

any news about script ?

bye
vic
0
 
LVL 3

Author Comment

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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction How to create multiboot configuration with XP\Vista and Windows 7 on it? And most important question - how to do this correctly so not to have any kind of nightmares we get when system gets screwed? First of all one should realize t…
In a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

813 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

10 Experts available now in Live!

Get 1:1 Help Now