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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
07-07-2011, 07:25 AM
|
#1
|
Member
Registered: Aug 2008
Location: France
Posts: 695
Rep:
|
"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.
|
|
|
07-07-2011, 07:36 AM
|
#2
|
Moderator
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
|
Try it with
Code:
kill -HUP $(pidof inetd)
Works for me.
|
|
|
07-07-2011, 08:00 AM
|
#3
|
Member
Registered: Aug 2008
Location: France
Posts: 695
Original Poster
Rep:
|
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
|
|
|
07-07-2011, 09:08 AM
|
#4
|
Member
Registered: Jan 2010
Posts: 418
Rep:
|
|
|
|
07-07-2011, 09:14 AM
|
#5
|
Member
Registered: Jan 2010
Posts: 418
Rep:
|
or try this:
Code:
a=`pidof inetd`;kill -HUP $a
|
|
|
07-07-2011, 09:15 AM
|
#6
|
Senior Member
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847
Rep: 
|
Alternatively, if you have pkill:
|
|
|
07-07-2011, 09:16 AM
|
#7
|
Member
Registered: Jan 2010
Posts: 418
Rep:
|
This would also work:
Code:
(echo -n "kill -HUP ";pidof inetd)|/bin/sh
|
|
|
07-07-2011, 11:29 AM
|
#8
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
Quote:
Originally Posted by littlebigman
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?
|
|
|
07-08-2011, 03:56 AM
|
#9
|
Member
Registered: Aug 2008
Location: France
Posts: 695
Original Poster
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 08:24 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|