易截截图软件、单文件、免安装、纯绿色、仅160KB

Linux脚本编写基础(五)

实例)
现在我们来讨论编写一个脚本的一般步骤。任何优秀的脚本都应该具有帮助和输入参数。并且写一个伪脚本(framework.sh),该脚本包含了大多数脚本都需要的框架结构,是一个非常不错的主意。这时候,在写一个新的脚本时我们只需要执行一下copy命令:
cp framework.sh myscript
然后再插入自己的函数。
让我们再看两个例子:
二进制到十进制的转换
脚本b2d 将二进制数 (比如 1101) 转换为相应的十进制数。这也是一个用expr命令进行数学运算的例子:


#!/bin/sh 

# vim: set sw=4 ts=4 et: 

help() 



cat < 

b2h -- convert binary to decimal 

USAGE: b2h [-h] binarynum 

OPTIONS: -h help text 

EXAMPLE: b2h 111010 
10 
will return 58 
11 
HELP 
12 
exit 0 
13 

14 
error() 
15 

16 
# print an error and exit 
17 
echo "$1" 
18 
exit 1 
19 

20 
lastchar() 
21 

22 
# return the last character of a string in $rval 
23 
if [ -z "$1" ]; then 
24 
# empty string 
25 
rval="" 
26 
return 
27 
fi 
28 
# wc puts some space behind the output this is why we need sed: 
29 
numofchar=`echo -n "$1" | wc -c | sed 's/ //g' ` 
30 
# now cut out the last char 
31 
rval=`echo -n "$1" | cut -b $numofchar` 
32 
}
33 
 
34 
chop() 
35 

36&nbs


相关文档:

实战Linux Bluetooth编程(三) HCI层编程

1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI)  就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......

linux oracle 安装

linux下oracle安装:
Oracle公司宣称在Linux下安装Oracle9i数据库至少要有512MB的内存和至少1GB或者两倍     
内存大小的交换空间,对于系统内存大于2GB的服务器,交换空间可以介于2GB—4GB之间。     
如果是为了在一台仅有256M内存的普通PC机上试用Oracle9 ......

打败Linux系统中的Bug

来源: http://www.xxlinux.com/linux/article/accidence/technique/20070125/7209.html
User Debug 日志记录

调试一个崩溃的程序的第一步是弄清哪里出了错。zSeries 上的Linux内核具有这样一个内置特性,它在用户进程崩溃时记录一些基本的调试信息。要启用这个特性,请以 root 用户身份执行如下命令:
echo 1 >& ......

linux install memcached,Linux安装memcached

rz上传文件到某目录
解压缩 tar zxvf
进入libevent目录 ./configure
转到root用户 make install
进入memcached目录 ./configure
转到root用户 make install
启动memcached
cd /usr/local/bin
/usr/local/bin/memcached -d -P /var/local/logs/memcached.pid -t 4 -m 200 -u root -c 1024 -v >> /var/local/l ......

linux 2.6 内核模块的Makefile



 
Linux 2.6 下内核模块的Makefile
收藏



Linux 2.6 下内核模块的Makefile
# Makefile 2.6
obj-m += hello.o
KDIR:=/lib/modules/$(shell uname -r)/build
# PWD=$(shell pwd)
all:
 &n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号