In a Bash script:
#!/usr/bin/bash
#grep()
#{
#grep -q
#}
if [[ -z $1 ]];
then
echo "usage: pkill -signal process name "
fi
if [[ -z $2 ]];
then
echo "error: not enough parameters "
exit
fi
kill9="9"
kill15="15"
if [ $1 -eq $kill9 ]
then
set "9"
else
set "15"
fi
ARRAY=(
`ps -ef|grep $2 |grep -v grep|awk '{print \$2}'`
)
pkill()
{
PIDTODIE=${2}
for i in ${ARRAY[@]} ;do kill $1 $i;done
}
pkill $1 $2
Is it possible to assign in awk
, $2
so that it becomes $b
? Because $2
is a Bash parameter and gives me conflicts. Also the \$2
is not working.
;-)
(notice how your code nicely matches the code injection vulnerability example I give in my answer there). – Stéphane Chazelas Dec 05 '14 at 12:00awk
before and hadn't realized that they too required quoting there. That code snippet was a copy/paste from a SO Q&A that I referenced, BTW. I'll edit that one as well. I'm that proficient w/ AWK. – slm Dec 05 '14 at 12:36my_var=4
and an example further down that includedmy_var="$some_other"
, so it was all my bad. – slm Dec 05 '14 at 12:40