tried this inside the awk its compiling but not giving the desired result it goes in an infinite loop
while (read "/u/Test/programs" )
{
getline pgmname< "/u/Test/programs"
if (pgmname == cmd_name)
{ kill=1}
}
I am a novice in shell.if you can help me in any way.it would be greatful
thanks.
---------- Post updated at 06:05 PM ---------- Previous update was at 05:07 PM ----------
another way i figured out was.
list=`cat /u/Test/programs`;
for line in $list
do
psg "ServTest" | awk -v pgmname=$line '{
cmd_name=($5 ~ /^[A-Z]/)? $9:$8
if (pgmname== cmd_name)
}'
done
Really not able to understand the purpose of the program...
if you want to read the filecontent of a file provide the filename to the awk at the end it read it line by line only to access the specific file inside the awk use FILENAME variable inside awk..(see man page)..
list=`cat /u/Test/programs`;
for line in $list
do
psg "ServTest" | awk -v pgm_name=$line '{
cmd_name=($5 ~ /^[A-Z]/)? $9:$8
gsub(/[[:space:]]*/,"",pgm_name)
gsub(/[[:space:]]*/,"",cmd_name)
if (pgm_name== cmd_name)
{ kill = 1;}
#further code is for kill if kill = 1
}'
done
thankss and regards
---------- Post updated at 06:40 PM ---------- Previous update was at 06:35 PM ----------
i have a file name programs in which there is a list of program names.
i want to kill all those process who are listed on this file and have no tty id
list=`cat /u/Test/programs`;
for line in $list
do
psg -t "?" | awk -v pgm_name=$line '{
cmd_name=($5 ~ /^[A-Z]/)? $9:$8
gsub(/[[:space:]]*/,"",pgm_name)
gsub(/[[:space:]]*/,"",cmd_name)
if (pgm_name== cmd_name)
{ kill = 1;}
#further code is for kill if kill = 1
}'
done
this code is working fine. if you find any better way to do this please tell