Results 1 to 5 of 5
Hi all,
i been writting bash script for couple of months now, i was jus puzzled on how can i do this :
Untitled.jpg
If you look at wat i ...
- 10-11-2011 #1Just Joined!
- Join Date
- Jun 2008
- Posts
- 5
Bash scripting with status indication
Hi all,
i been writting bash script for couple of months now, i was jus puzzled on how can i do this :
Untitled.jpg
If you look at wat i wan is basically, having a statement being wrtting something like :
all in the same vertical line and horizontal line of that statement.Code:Daemon Started [ Done ] Daemon Listening [ Fault ]
today i could only do something like :
it basically in same vertical line but not in same horizontal line.Code:Daemon Started [Done] Daemon Listening [Fault]
it has to skip 1 line.
i do it by adjusting "echo -e" & "echo -en"
can someone explain how can i achieve something like picture above.
- 10-12-2011 #2Just Joined!
- Join Date
- Jan 2011
- Location
- Fairfax, Virginia, USA
- Posts
- 94
Hi, the mechanism for how the init.d scripts works changes on your distribution. In Redhat and Fedora, its done with a script in /etc/init.d calling /etc/rc.d/init.d/functions which has a bash function in it called deamon I think.
Anyway, to achieve what you want, the left hand side could be done with something like:
then the right hand side could be done with something like:Code:echo -n Deamon
If you want to color code it, you can follow this web page for examples:Code:echo Success
Bash Colours
- 10-12-2011 #3Just Joined!
- Join Date
- Jun 2008
- Posts
- 5
Thanks for reply
Thanks for replying,
I have actually tried that but it doesnt really get a proper vertical line, example all i get is :
It is based on the length of characters on the left then only on the right prints out based on the tabs or spaces.Code:Starting Deamon [Done] starting Listining to Deamon [Fault]
but thats not what or how i would like to have it.
i practically am trying to hv it in sync in 1 line
- 10-12-2011 #4
check printf manual page instead of using echo
- 10-12-2011 #5Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
If you want to replicate the OK/FAILED messages at init (like in your posted pic), you could do something like:
It will evaluate the exit code from your prog and show either OK or FAILED.Code:#!/bin/bash # source function library . /etc/init.d/functions # run your prog/script/command action $"Running my prog: " /path/to/prog
If you want to do your own message, then just look at the /etc/init.d/functions and see what they do with RES_COL, MOVE_TO_COL and SETCOLOR_*


Reply With Quote
