kill: bad argument count


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting kill: bad argument count
# 1  
Old 09-26-2012
kill: bad argument count

Hi Team,

I am getting the below error when running the script. Please let me know how to solve this error.
Code:
start_WFA.sh[9]: kill: bad argument count

Below is the Script:
Code:
#!/bin/ksh
kill -9 `ps -ef|grep classpath |grep "/apps/ap" |grep -v "Xmx" |grep $LOGNAME |awk '{print $2}'`

Thanks,

Last edited by Franklin52; 09-26-2012 at 06:48 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 09-26-2012
And, how does kill respond if you just type kill -9 on the command line?
What's the output of that command in back-ticks?
# 3  
Old 09-26-2012
Most likely, no process qualifies for being killed. Try
Code:
PIDS=`ps -ef|grep classpath |grep "/apps/ap" |grep -v "Xmx" |grep $LOGNAME |awk '{print $2}'`
[ -n "$PIDS" ] && kill -9 $PIDS

# 4  
Old 09-26-2012
Check for the below command output.
Code:
ps -ef|grep classpath |grep "/apps/ap" |grep -v "Xmx" |grep $LOGNAME |awk '{print $2}'

This must return something valid for kill. i.e. integer/process_name in your case.
# 5  
Old 09-26-2012
Issue resolved

Quote:
Originally Posted by hergp
Most likely, no process qualifies for being killed. Try
Code:
PIDS=`ps -ef|grep classpath |grep "/apps/ap" |grep -v "Xmx" |grep $LOGNAME |awk '{print $2}'`
[ -n "$PIDS" ] && kill -9 $PIDS

The issue resolved by using the above command

We are getting the output for the below command
--------------------------------------
Code:
appodev:>ps -ef|grep classpath |grep "/apps/ap" |grep -v "Xmx" |grep $LOGNAME |awk '{print $2}'
15577

------------------------------------------

Can you tell me what this command do ?
Code:
[ -n "$PIDS" ] && kill -9 $PIDS


Thank you all for your quick help.

Last edited by Franklin52; 09-26-2012 at 06:49 AM.. Reason: Please use code tags for data and code samples
# 6  
Old 09-26-2012
If you aren't aware of their existences, most systems have pgrep and pkill, which in many cases can replace a fragile, underspecified pipeline with a more rigorous and portable simple command.

Regards,
Alister
This User Gave Thanks to alister For This Post:
# 7  
Old 09-26-2012
Quote:
Originally Posted by Mukharam Khan
Can you tell me what this command do ?
Code:
[ -n "$PIDS" ] && kill -9 $PIDS

Thank you all for your quick help.
The PIDS variable contains a list of pids, which qualify for being killed. Now if the variable is NOT empty ( [ -n "$PIDS" ] ) then kill them all. && is a logical AND which can be used as a short form of an if-then-fi construct.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Kill an specific process ID using the KILL and GREP commands

Good afternoon I need to KILL a process in a single command sentence, for example: kill -9 `ps -aef | grep 'CAL255.4ge' | grep -v grep | awk '{print $2}'` That sentence Kills the process ID corresponding to the program CAL255.4ge. However it is possible that the same program... (6 Replies)
Discussion started by: enriquegm82
6 Replies

2. Ubuntu

Bad argument `5666'

Hello, When I type this command: iptables -I RH-Firewall-1-INPUT -p tcp -m tcp -dport 5666 -j ACCEPTit returns me :Bad argument `5666' Try `iptables -h' or `iptables --help' for more information. (5 Replies)
Discussion started by: inserm
5 Replies

3. UNIX for Advanced & Expert Users

Error:--test: argument expected--Even though i give an argument.

Hi All, I am running the script VBoxManage list vms |sed 's/"//g' | cut -d " " -f1 > har1out.mytxt result=`cat har1out.mytxt | grep $1' echo $result echo $1 { if then echo pass else echo fail fi (2 Replies)
Discussion started by: harsha85
2 Replies

4. Shell Programming and Scripting

Why I get bad bad substitution when using eval?

Why I get bad replace when using eval? $ map0=( "0" "0000" "0") $ i=0 $ eval echo \${map$i} 0000 $ a=`eval echo \${map$i}` !!!error happens!!! bash: ${map$i}: bad substitution How to resolve it ? Thanks! (5 Replies)
Discussion started by: 915086731
5 Replies

5. Shell Programming and Scripting

Cannot compare argument in if statement in csh/grep command if argument starts with “-“

If ($argv == “-debug”) then Echo “in loop” Endif But this is not working. If I modify this code and remove “-“, then it works. Similarly I am getting problem using grep command also Grep “-debug” Filename Can someone please help me on how to resolve these... (1 Reply)
Discussion started by: sarbjit
1 Replies

6. Linux

Serial terminal emulation - bad row column count ?

Hello, I connect to linux using serial cable from windows machine. I use putty as serial terminal emulator. Everything works fine except programs which scroll text - man, more, less, vi, etc.. These programs asumme my terminal size is 80cols x 24rows (my putty window size is more than that,... (1 Reply)
Discussion started by: vilius
1 Replies

7. Shell Programming and Scripting

argument count

I'm writing a program that takes input from the user of a phone number or a name then either tells them if that entry doesn't exist in a text document or returns the entry if it does exist. But if they enter a name AND number it either returns the entry if it exists or adds it to the document. To... (17 Replies)
Discussion started by: javajynx
17 Replies

8. Shell Programming and Scripting

bad argument count, tryig to FTP

I have a file in a Unix directory called 97210900.EFT I am getting this error: miis_ftp.ELM_EFT.shl: cd: bad argument count + + type=1 + ErrorHandle Here is the piece of code that is checking the file # Change the directory to one contains the file to be transported ##cd... (1 Reply)
Discussion started by: rechever
1 Replies

9. Shell Programming and Scripting

get positive number n as argument script must calculate the factorial of its argument

Can someone please help me with this SHELL script? I need to create a script that gets a positive number n as an argument. The script must calculate the factorial of its argument. In other words, it must calculate n!=1x2x3x...xn. Note that 0!=1. Here is a start but I have no clue how to... (3 Replies)
Discussion started by: I-1
3 Replies

10. UNIX for Advanced & Expert Users

When kill doesnt work, how to kill a process ?

Hi All, I am unable to kill a process using kill command. I am using HP-UX system. I have tried with kill -9 and i have root privilages. How can i terminate this daemon ? ? ? Regards, Vijay Hegde (3 Replies)
Discussion started by: VijayHegde
3 Replies
Login or Register to Ask a Question