Results 1 to 8 of 8
Hai,
I want to display the process id of a daemon along with its name
eg: pidof java and the output of my script to be
tomcat (pid 123423) is ...
- 06-09-2008 #1Just Joined!
- Join Date
- Apr 2007
- Posts
- 5
Bourne shell help in displaying output
Hai,
I want to display the process id of a daemon along with its name
eg: pidof java and the output of my script to be
tomcat (pid 123423) is running ...
but if i do like
echo -n "tomcat ("
pidof java
echo -n ) is running
the output is not obtaining in a single line a newline character is inserted after the command "pidof" . if there is any method to remove the newline after the command "pidof" please help
- 06-09-2008 #2
Try this:
Hope this helps.Code:#!/bin/bash echo $(echo -n "tomcat (" /pidof java echo -ne "\b) is running" )--
Bill
Old age and treachery will overcome youth and skill.
- 06-09-2008 #3Just Joined!
- Join Date
- Apr 2007
- Posts
- 5
Thank you for your reply
Unfortunately it is not working saying that
: command not found
test: line 6 /pidof: No such file or directory
) is running
Note: i named the file test
- 06-09-2008 #4
My mistake. Sorry. Sloppy copying and pasting.

Remove the slash from just before the pidof. That leaves this:
Code:#!/bin/bash echo $(echo -n "tomcat (" pidof java echo -ne "\b) is running" )--
Bill
Old age and treachery will overcome youth and skill.
- 06-09-2008 #5Linux User
- Join Date
- Aug 2006
- Posts
- 458
- 06-10-2008 #6Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
- 06-10-2008 #7This will work:Not sure how printf can be used to remove a newline, care to enlighten us?
Code:#!/bin/bash printf "tomcat %s is running" $(pidof java)
--
Bill
Old age and treachery will overcome youth and skill.
- 06-11-2008 #8Linux User
- Join Date
- Aug 2006
- Posts
- 458


Reply With Quote
