如何写像init.d中使用的那些bash脚本? [英] how to write a bash script like the ones used in init.d?

查看:88
本文介绍了如何写像init.d中使用的那些bash脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须写一个bash脚本,使得很多东西。我想打印的消息像你一样初始化脚本做。例如:

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?

在此先感谢

推荐答案

在我所有的Linux箱,code这样做是在文件中:

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

/etc/init.d/functions

如果您包含文件( /etc/init.d/functions ),然后运行code这样做:

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.

这篇关于如何写像init.d中使用的那些bash脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆