LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-07-2011, 07:25 AM   #1
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 658

Rep: Reputation: 35
Question "kill" doesn't like "pidof"


Hello

A script uses the following command:
Code:
root:/var/tmp> pidof inetd
55

root:/var/tmp> kill -HUP `pidof inetd`
kill: bad pid '`pidof'
kill: bad pid 'inetd`'
Since "pidof" by itself works fine, does someone know why "kill" can't use its output?

Thank you.
 
Old 07-07-2011, 07:36 AM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Try it with
Code:
kill -HUP $(pidof inetd)
Works for me.
 
Old 07-07-2011, 08:00 AM   #3
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 658

Original Poster
Rep: Reputation: 35
Thanks for the tip, but it doesn't work with the Hush shell that I use on an appliance :-/

Code:
root:/var/tmp> kill -HUP $(pidof inetd)
sh: syntax error: unexpected )

root:/var/tmp> echo $SHELL
/bin/sh

root:/var/tmp> ls -al /bin/*sh
lrwxrwxrwx    1 root     root             7 Jul  6  2011 /bin/hush -> busybox
lrwxrwxrwx    1 root     root             7 Jul  6  2011 /bin/sh -> busybox
 
Old 07-07-2011, 09:08 AM   #4
16pide
Member
 
Registered: Jan 2010
Posts: 418

Rep: Reputation: 83
why not:
Code:
killall -HUP inetd
 
Old 07-07-2011, 09:14 AM   #5
16pide
Member
 
Registered: Jan 2010
Posts: 418

Rep: Reputation: 83
or try this:
Code:
a=`pidof inetd`;kill -HUP $a
 
Old 07-07-2011, 09:15 AM   #6
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Alternatively, if you have pkill:
Code:
pkill -HUP inetd
 
Old 07-07-2011, 09:16 AM   #7
16pide
Member
 
Registered: Jan 2010
Posts: 418

Rep: Reputation: 83
This would also work:
Code:
(echo -n "kill -HUP ";pidof inetd)|/bin/sh
 
Old 07-07-2011, 11:29 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by littlebigman View Post
Code:
root:/var/tmp> pidof inetd
55

root:/var/tmp> kill -HUP `pidof inetd`
kill: bad pid '`pidof'
kill: bad pid 'inetd`'
Since "pidof" by itself works fine, does someone know why "kill" can't use its output?
The error message shows kill is not getting the output of pidof inetd but the two words `pidof and inetd`; hush is not interpreting the backquote characters in the usual sh-derivative shell way.

Does hush support command substitution?
 
Old 07-08-2011, 03:56 AM   #9
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 658

Original Poster
Rep: Reputation: 35
Thanks for the idea, that was it: By default "Process substitution" is not enabled. After adding it and recompiling, the command runs OK.

Thanks everyone for the feedback.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ - "snprintf" inside "for" doesn't work as expected. (int to char*) Repgahroll Programming 14 08-31-2010 08:27 AM
Chromium doesn't save "default browser"+ Desktop isn't "snappy" ohadbasan Arch 1 01-25-2010 08:07 PM
What does "Directory "/usr/src/linux" doesn't appear to contain kernel source." mean? jtp51 Linux - General 4 06-11-2007 12:22 AM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 08:31 AM
suse 10.0 => processes "sending kill signal": "done, done, missing"...!? ungua Linux - Newbie 2 01-18-2006 10:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:12 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration