Archive for the ‘Shell编程’ Category

expect

07.28.2009 by sunliguo - 0 Comment
Posted in Linux, Shell编程

在写一些shell脚本的时候,经常会遇到需要用户输入密码的交互情况。
例如在用rsync备份的时候,如果没有假设rsync服务器端,需要用到ssh+rsync备份,没有提供输入密码的选项。上网上查了一下,有个expct的交互程序。
expect也够复杂的,起码在我看来是这样。先找个可以输入密码的实例:见
http://www.blog.ccidnet.com/blog-htm-do-showone-uid-73559-itemid-238796-type-blog.html Read the rest of this entry

Shell 笔记

07.12.2009 by sunliguo - 0 Comment
Posted in Shell编程

1:保存命令的结果
$(ls -l /) 或者 `ls -l /`
2:判断 [[]] 与 []
[ -z $(ls -l /)] 或者 test
一个目录是否为空: [[ -z $(ls /a)]]||&&echo empty|| echo “not empty” Read the rest of this entry

字符编码转换的脚本

07.08.2009 by sunliguo - 0 Comment
Posted in Shell编程

程序中遇到汉字真是麻烦,弄的程序原本是gbk或者是gb2312的。现在服务器上都是utf-8,汉字全是乱码。只好写个shell,来自动转换。 Read the rest of this entry

shell 参数替换

07.02.2009 by sunliguo - 0 Comment
Posted in Shell编程

今天在分析一个shell脚本的时候遇到了一个变量 ${2:15}。经我查阅shell经典参考书ABS后,得到如下解释: Read the rest of this entry

我要自己动手做个网站

06.23.2009 by sunliguo - 4 Comments
Posted in Shell编程

我要自己做个网站,用shell scripts写cgi程序。 Read the rest of this entry

山东地区手机号的余额

05.25.2009 by sunliguo - 0 Comment
Posted in Linux, Shell编程

从山东移动的官方网站上充值的时候,会提示你的余额还有多少。不管手机号是谁的,只要是山东的号就行。因此想到通过curl提交一个这个表单,来查询某个手机号的余额。
通过查看提交手机号的表单,有几个是隐藏的控件。提交的POST数据,是通过抓包来获取的。
下边是一个POST数据的例子: Read the rest of this entry

curl

05.15.2009 by sunliguo - 0 Comment
Posted in Linux, Shell编程

Linux 下的这些小工具实在是太有用了。一个个顺手的工具,用shell脚本连接起来就是个强大的工具。 Read the rest of this entry