Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to write a bash script like the ones used in init.d?

Tags:

bash

scripting

I have to write a bash script that makes lot of things. I'd like to print messages as nice as init scripts do. For example:

 Doing A... [OK]  
 Doing B... [ERROR]  
 ....

Do you know any way to make this?

Thanks in advance

like image 276
Neuquino Avatar asked Mar 22 '10 18:03

Neuquino


1 Answers

On all my Linux boxes, the code to do that is in the file:

/etc/init.d/functions

If you include that file (. /etc/init.d/functions) and then run your code doing this:

action /path/to/prog args

you will get the functionality you want.

like image 65
R Samuel Klatchko Avatar answered Oct 23 '22 13:10

R Samuel Klatchko