LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-04-2006, 02:44 AM   #1
tara
Member
 
Registered: Aug 2005
Location: Australia
Distribution: Mageia 1
Posts: 53

Rep: Reputation: 15
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
 
Old 05-04-2006, 02:52 AM   #2
zulfilee
Member
 
Registered: Apr 2004
Location: India
Distribution: Redhat,Fedora
Posts: 430

Rep: Reputation: 39
SIGINT is interrupt from keyboard
That can be one reason why it is not working non-interactively.
 
Old 05-04-2006, 03:01 AM   #3
tara
Member
 
Registered: Aug 2005
Location: Australia
Distribution: Mageia 1
Posts: 53

Original Poster
Rep: Reputation: 15
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
 
Old 05-04-2006, 08:41 AM   #4
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 30
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 ...
 
Old 05-04-2006, 08:47 AM   #5
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 53
killall -TERM kwrite
if it has been blocked by the application, then
killall -KILL kwrite
 
Old 05-04-2006, 07:05 PM   #6
tara
Member
 
Registered: Aug 2005
Location: Australia
Distribution: Mageia 1
Posts: 53

Original Poster
Rep: Reputation: 15
thanks guys

both ways worked perfectly

cheers

Tara
 
Old 02-09-2009, 12:50 AM   #7
ravisingla
LQ Newbie
 
Registered: Jan 2009
Posts: 2

Rep: Reputation: 0
Sending SIGUSR1

Quote:
Originally Posted by nx5000 View Post
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??
 
Old 02-09-2009, 04:57 AM   #8
kauuttt
Member
 
Registered: Dec 2008
Location: Kolkata, India
Distribution: Ubuntu
Posts: 123

Rep: Reputation: 25
Quote:
Originally Posted by ravisingla View Post
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);
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
escape string in bash script so it can be used in command line BuckRogers01 Linux - Software 15 08-12-2010 10:38 AM
bash script 'for each command line argument' true_atlantis Linux - Newbie 3 01-28-2009 02:51 PM
Bash Script, no new line for echo command jorisb Linux - General 5 11-05-2005 01:08 AM
shell script works form command line but not form crontab saifee General 1 10-14-2004 11:27 AM
Perl shell-out to script dunna work. Works on command line. Why? jlangelier Linux - Software 1 08-28-2004 03:00 AM


All times are GMT -5. The time now is 03:38 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration