home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
dialip2.zip
/
killbn.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-01-31
|
2KB
|
79 lines
/* program: killbyname (a freeby)
** written: Stan J. Towianski
** purpose: killbyname arg, will kill the 1st process that matches the
** name given in arg.
** date: 1995
** note: needs to have kill.exe program in path.
** This can be found in c:\grpware\clients from OS/2 Warp 3.0
*/
parse upper arg options searchname num_to_kill
/*say 'entered with options ='options'=' 'searchname ='searchname'='*/
dosrc = rxqprocstatus('q.','')
just_find_flag = 'N'
return_hex_flag = 'N'
decpid = -1
pid = -1
if ( left( options, 1 ) \= '-' ) then
Do
num_to_kill = searchname
searchname = options
End
else if ( pos( '-FX', options ) > 0 ) then
Do
just_find_flag = 'Y'
return_hex_flag = 'Y'
End
else if ( pos( '-F', options ) > 0 ) then
just_find_flag = 'Y'
n = 1
parse var searchname searchname.n ',' searchname
say 'will kill session ='searchname.n'='
do while( searchname \= '' )
n = n + 1
parse var searchname searchname.n ',' searchname
say 'will kill session ='searchname.n'='
End
searchname.0 = n
left_to_kill = n
Say 'There are' q.0p.0 'processes ('q.0g.1 'threads) running right now'
do n=1 to q.0p.0 /* number of processes */
/* say;say '==== Process ('q.0p.n.1')'q.0p.n.6' ===='*/
pid = q.0p.n.1
procname = q.0p.n.6
/* say "pid ="pid "procname ="procname"="*/
do_kill = NO
do c = 1 to searchname.0
if ( pos( searchname.c, procname ) > 0 ) then
Do
do_kill = YES
leave
End
End
if ( do_kill = YES ) then
Do
decpid = x2d( pid )
if ( just_find_flag = 'Y' ) then
Do
/* say 'found name with hex pid = 'pid 'decpid = 'decpid*/
leave
End
"kill "decpid
left_to_kill = left_to_kill - 1
if ( left_to_kill < 1 ) then
Do
say 'killed all sessions'
leave
End
End
End
if return_hex_flag = 'Y' then
return pid
else
return decpid