LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Linux shell script for stop/start Tomcat (https://www.linuxquestions.org/questions/linux-general-1/linux-shell-script-for-stop-start-tomcat-4175549244/)

tranphat 07-29-2015 05:29 AM

Linux shell script for stop/start Tomcat
 
Dear all,

I have 1 small problem with the script for start/stop tomcat server.

--------- Here is my start command ------------

start() {
pid=$(tomcat_pid)
if [ -n "$pid" ]
then
echo "Tomcat is already running (pid: $pid)"
else
echo "Starting tomcat"
/bin/su -p -s /bin/sh $TOMCAT_USER $TOMCAT_HOME/bin/startup.sh > /dev/null 2>&1
fi
return 0
}

-------- Here is how I call the command --------
case $1 in
start)
start
rc_status -v
;;
stop)
stop
rc_status -v
;;

restart)
stop
sleep 5
start
;;
-------------------------------

The script above works fine, but: the message "done" is not on the same line with "Starting Tomcat"

tomct2v:~ # /etc/init.d/tomcat7 start
Starting tomcat
done

Are there any ways to make "Starting tomcat" and "done" on the same line?

wpeckham 07-29-2015 05:42 AM

RTFM
 
Check the man page for 'echo'.

All you need do is suppress the output of a newline.
In current GNU versions of echo, and the bash internals, the -n parameter should help.

tranphat 07-29-2015 10:48 PM

Quote:

Originally Posted by wpeckham (Post 5397713)
Check the man page for 'echo'.

All you need do is suppress the output of a newline.
In current GNU versions of echo, and the bash internals, the -n parameter should help.

Hello wpeckham,

It works, thank you so much :)


All times are GMT -5. The time now is 10:19 PM.