-
Archives
- March 2012
- December 2011
- March 2011
- December 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- January 2010
- December 2009
- October 2009
- September 2009
- August 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
-
Meta
Category Archives: Shell
一个打包下载VOA的shell脚本
请注意06年下半年(7月份以后)的地址变了,是这样的:
http://download.putclub.com/update/standard/VOA/200607/2006VOA0701.mp3
可以把脚本稍做修改,然后接着下后半年的,当然也可以在脚本中做个判断,自动选择,懒得弄了:-[......]
Posted in Shell, 编程相关
2 Comments
CNC的脚本再次更新
- 加了几个简单的注释,怕时间长了不记得了。
- 修改/etc/syslog.conf文件后重起syslog进程,这样就不用重启电脑了。
- 修改每次在IFCFG文件中更改用户使用的方法,以前那种方式会造成在F7中产生两个USER选项。
- 增加对IFCFG文件的存在测试。
- 对IFCFG文件中[......]
Posted in Shell, 编程相关
2 Comments
ADSL脚本更新
1.添加了自动修改/etc/syslog.conf文件,不需要手动更改,使得脚本更方便。
2.分析日志文件时,添加判断eth0是否被激活,未激活的情况下首先激活eth0,不过请确保使用脚本时eth0状态是激活。
3.对pppd进程数目的判断改为在一个循环中查询,更智能一些。
4.当未查询到密码[......]
Posted in Shell, 编程相关
15 Comments
一个shell脚本
在Fedora core 5下测试成功,目前的脚本只是针对XXXX的帐号,稍做修改可以试用于各种ADSL拨号。使用需要root仅限,请先修改/etc/syslog.conf文件,在最后添加:
# cocobear add
loca12.*[......]
Posted in Shell, 编程相关
2 Comments
使用awk消除行号
在读ABS(Advanced Bash-Scripting Guide)的时候,遇到书中的示例代码如下:
1 #!/bin/bash
2 # broken-link.sh
3 # Written by Lee bigelow >ligelowbee@yahoo.com< 4 # Used with permission.
5
6 #A pure shell script to find dead symlinks and output them quoted
7 #so they can be fed to xargs and dealt with
8 #eg. broken-link.sh /somedir /someotherdir|xargs rm
9 #
10 #This, however, is a better method:
11 #
12 #find "somedir" -type l -print0|\
13 #xargs -r0 file|\
14 #grep "broken symbolic"|
15 #sed -e 's/^\|: *broken symbolic.*$/"/g'
16 #
17 #but that wouldn't be pure bash, now would it.
18 #Caution: beware the /proc file system and any circular links!
19 ###################################
20
21
22 #If no args are passed to the script set directorys to search
23 #to current directory. Otherwise set the directorys to search
24 #to the agrs passed.
25 ####################
26 [ $# -eq 0 ] && directorys=`pwd` || directorys=$@
27
28 #Setup the function linkchk to check the directory it is passed
29 #for files that are links and don't exist, then print them quoted.
30 #If one of the elements in the directory is a subdirectory then
31 #send that send that subdirectory to the linkcheck function.
32 ##########
33 linkchk () {
34 for element in $1/*; do
35 [ -h "$element" -a ! -e "$element" ] && echo \"$element\"
36 [ -d "$element" ] && linkchk $element
37 # Of course, '-h' tests for symbolic link, '-d' for directory.
38 done
39 }
40
41 #Send each arg that was passed to the script to the linkchk function
42 #if it is a valid directoy. If not, then print the error message
43 #and usage info.
44 ################
45 for directory in $directorys; do
46 if [ -d $directory ]
47 then linkchk $directory
48 else
49 echo "$directory is not a directory"
50 echo "Usage: $0 dir1 dir2 ..."
51 fi
52 done
53
54 exit 0
想复制下来自己执行一下,无奈每行都有行号,不能直接做为shell脚本执行,当然不甘心了,于是想到强大的awk,写了如下awk脚本:
{
i=2;
while (i >= NF)[......]
Posted in Shell, 编程相关
2 Comments