LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   works on command line but not in bash script (https://www.linuxquestions.org/questions/linux-general-1/works-on-command-line-but-not-in-bash-script-441465/)

tara 05-04-2006 01:44 AM

works on command line but not in bash script
 
Hi

(lets say i want to kill the kwrite application)

if i run the following on the command line:

kill -s SIGINT `ps -C kwrite -o pid h`

but if i put that exact line in a script i get the following error:
kill: SIGINT: invalid signal specification

and the command doesn't work

do anyone know why or how to fix.

thanks
Tara


p.s. using #!/bin/sh

zulfilee 05-04-2006 01:52 AM

SIGINT is interrupt from keyboard
That can be one reason why it is not working non-interactively.

tara 05-04-2006 02:01 AM

thanks zulfilee


is there any way to send keyboard signals from a script, i don't really want to kill the process using the kill command directly hence why trying SIGINT. SIGINT provides a clean way of shutting down the other related processes.

Tara

ioerror 05-04-2006 07:41 AM

Quote:

SIGINT is interrupt from keyboard
That can be one reason why it is not working non-interactively.
Doesn't matter, kill can send any signal.

The problem is that you don't need the SIG, just use kill -s INT ...

nx5000 05-04-2006 07:47 AM

killall -TERM kwrite
if it has been blocked by the application, then
killall -KILL kwrite

tara 05-04-2006 06:05 PM

thanks guys

both ways worked perfectly :)

cheers

Tara

ravisingla 02-08-2009 11:50 PM

Sending SIGUSR1
 
Quote:

Originally Posted by nx5000 (Post 2230525)
killall -TERM kwrite
if it has been blocked by the application, then
killall -KILL kwrite

I am trying to send SIGUSR1 from a c programm
system("kill -SIGUSR1 'cat /var/run/process.pid'");
but facing the same problem i.e. i am getting error invalid signal specification
But from konsole if I try to send then does not give any problem.. Can you please help whats wrong with this??

kauuttt 02-09-2009 03:57 AM

Quote:

Originally Posted by ravisingla (Post 3436770)
I am trying to send SIGUSR1 from a c programm
system("kill -SIGUSR1 'cat /var/run/process.pid'");
but facing the same problem i.e. i am getting error invalid signal specification
But from konsole if I try to send then does not give any problem.. Can you please help whats wrong with this??

try kill function...
kill(int pid, int signal);


All times are GMT -5. The time now is 06:32 PM.