xunwap

专注移动互联网服务

正在浏览 Linux 里的文章

在Linux下编写server的配置文件时,有两种标准的做法,一种是使用INI文件,一种是使用XML文件。
XML可以支持复杂的嵌套式的配置选项,而INI文件对于结构简单的配置文件则十分实用。
这里推荐一个有用的INI解析工具: INIParser
INIParser的使用比较简单,主要使用下面的函数:

使用: iniparser_load() 加载一个要解析的INI文件:
使用下面的函数来获取具体的INI选项的值:
 iniparser_getstring()
 iniparser_getint()
 iniparser_getdouble()
 iniparser_getboolean()
在解析完配置文件之后,使用下面的函数来释放解析INI文件时所使用的资源
 iniparser_freedict().

说明: 在定位具体的INI配置项时,使用”:”来分隔对应的”段名”和”配置项名”,比如”config_section:config_name”

本站原创文章,转载请注明出处。

记录一些特殊的linux shell 参数,在编写shell的过程中会用得上。

linux shell 预定义参数
名称 功能
$0 The name of the command being executed. For shell scripts, this is the path with which it was invoked.
$n These variables correspond to the arguments with which a script was invoked. Here n is a positive decimal number corresponding to the position of an argument (the first argument is $1,the second argument is $2, and so on).
$# The number of arguments supplied to a script.
$* All the arguments are double quoted. If a script receives two arguments, $* is equivalent to $1 $2.
$@ All the arguments are individually double quoted. If a script receives two arguments, $@ is equivalent to $1 $2.
$? The exit status of the last command executed.
$$ The process number of the current shell. For shell scripts, this is the process ID under which they are executing.
$! The process number of the last background command.

本站原创文章,转载请注明出处。