linux下的nbtstat–nbtscan

以前维护测试环境,经常遇到某一个测试或者开发跑压测,乱改数据,乱改配置等等。。总之最终需要我去把环境恢复好,最好不过的是再把这个人给抓出来。。之前是知道nbtstat基本可以根据IP查出对于的netbios名字,这个就能和工号对应起来了。
今天发现linux下其实有个类似的命令,netscan,而且还能批量扫描,更为强大。具体的使用man一下就行。

“Human-readable service names” (-h) option cannot be used without verbose (-v) option.
Usage:
nbtscan [-v] [-d] [-e] [-l] [-t timeout] [-b bandwidth] [-r] [-q] [-s separator] [-m retransmits] (-f filename)|()
-v verbose output. Print all names received
from each host
-d dump packets. Print whole packet contents.
-e Format output in /etc/hosts format.
-l Format output in lmhosts format.
Cannot be used with -v, -s or -h options.
-t timeout wait timeout milliseconds for response.
Default 1000.
-b bandwidth Output throttling. Slow down output
so that it uses no more that bandwidth bps.
Useful on slow links, so that ougoing queries
don’t get dropped.
-r use local port 137 for scans. Win95 boxes
respond to this only.
You need to be root to use this option on Unix.
-q Suppress banners and error messages,
-s separator Script-friendly output. Don’t print
column and record headers, separate fields with separator.
-h Print human-readable names for services.
Can only be used with -v option.
-m retransmits Number of retransmits. Default 0.
-f filename Take IP addresses to scan from file filename.
-f – makes nbtscan take IP addresses from stdin.
what to scan. Can either be single IP
like 192.168.1.1 or
range of addresses in one of two forms:
xxx.xxx.xxx.xxx/xx or xxx.xxx.xxx.xxx-xxx.
Examples:
nbtscan -r 192.168.1.0/24
Scans the whole C-class network.
nbtscan 192.168.1.25-137
Scans a range from 192.168.1.25 to 192.168.1.137
nbtscan -v -s : 192.168.1.0/24
Scans C-class network. Prints results in script-friendly
format using colon as field separator.
Produces output like that:
192.168.0.1:NT_SERVER:00U
192.168.0.1:MY_DOMAIN:00G
192.168.0.1:ADMINISTRATOR:03U
192.168.0.2:OTHER_BOX:00U

nbtscan -f iplist
Scans IP addresses specified in file iplist.

发表在 Admin | 留下评论

用nmap扫描OS类型

nmap里面可以根据FIN探查,无效标志探查,ISN采样,DF标志位监控,TCP初始化窗口大小,ACK的值,ICMP出错消息,ICMP消息内容,TOS字段,数据包拆分处理和一些其他的TCP选项来大概猜测远程OS的类型。
直接
[bash]
sudo nmap -O www.domain.com -D 8.8.8.8
[/bash]
就能对相应的主机进行扫描,-D是伪装IP 源。
[bash]
www.ebay.com

Starting Nmap 6.00 ( http://nmap.org ) at 2012-10-20 19:02 CST
Nmap scan report for www.ebay.com (66.211.181.181)
Host is up (0.56s latency).
Other addresses for www.ebay.com (not scanned): 66.211.181.161 66.135.210.181 66.135.210.61 66.135.200.181 66.135.200.161
Not shown: 998 filtered ports
PORT STATE SERVICE
80/tcp open http
443/tcp closed https
Device type: load balancer
Running (JUST GUESSING): Citrix embedded (85%)
Aggressive OS guesses: Citrix NetScaler load balancer (85%)
No exact OS matches for host (test conditions non-ideal).

OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 63.61 seconds
www.google.com

Starting Nmap 6.00 ( http://nmap.org ) at 2012-10-20 19:03 CST
Nmap scan report for www.google.com (74.125.128.147)
Host is up (0.049s latency).
Other addresses for www.google.com (not scanned): 74.125.128.106 74.125.128.105 74.125.128.104 74.125.128.103 74.125.128.99
rDNS record for 74.125.128.147: hg-in-f147.1e100.net
Not shown: 998 filtered ports
PORT STATE SERVICE
80/tcp open http
443/tcp open https
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running (JUST GUESSING): OpenBSD 4.X (85%)
OS CPE: cpe:/o:openbsd:openbsd:4.3
Aggressive OS guesses: OpenBSD 4.3 (85%)
No exact OS matches for host (test conditions non-ideal).

OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 11.11 seconds
www.bing.com

Starting Nmap 6.00 ( http://nmap.org ) at 2012-10-20 19:03 CST
Nmap scan report for www.bing.com (63.150.12.75)
Host is up (0.22s latency).
Other addresses for www.bing.com (not scanned): 63.150.12.33
rDNS record for 63.150.12.75: 63-150-12-75.dia.static.qwest.net
Not shown: 996 filtered ports
PORT STATE SERVICE
53/tcp closed domain
80/tcp open http
443/tcp open https
8000/tcp closed http-alt
Device type: WAP|media device|webcam|general purpose|PBX
Running (JUST GUESSING): Linux 2.6.X|2.4.X (95%), Asus Linux 2.6.X (94%), Linksys Linux 2.4.X (93%), Netgear embedded (92%), Western Digital embedded (92%), AXIS Linux 2.6.X (92%), Cisco Linux 2.6.X (91%)
OS CPE: cpe:/o:linux:kernel:2.6.22 cpe:/h:asus:rt-n16 cpe:/o:asus:linux:2.6 cpe:/o:linksys:linux:2.4 cpe:/o:linux:kernel:2.4 cpe:/o:axis:linux:2.6 cpe:/o:linux:kernel:2.6 cpe:/o:cisco:linux:2.6
Aggressive OS guesses: Tomato 1.28 (Linux 2.6.22) (95%), OpenWrt Kamikaze 7.09 (Linux 2.6.22) (95%), Asus RT-N16 WAP (Linux 2.6) (94%), OpenWrt White Russian 0.9 (Linux 2.4.30) (93%), OpenWrt 0.9 – 7.09 (Linux 2.4.30 – 2.4.34) (93%), Linux 2.6.15 (likely TP-Link WAP) (93%), Netgear DG834G WAP or Western Digital WD TV media player (92%), AXIS 211A Network Camera (Linux 2.6.20) (92%), Linux 2.6.15 – 2.6.24 (embedded) (91%), Linux 2.6.22 – 2.6.36 (91%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 16 hops

OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 21.27 seconds

[/bash]

当然,如果想扫描一下开的端口啥的直接-sS扫描吧,也可以选ACK扫描,那就-sA

pm@debian:~sudo nmap -sS www.baidu.com

Starting Nmap 6.00 ( http://nmap.org ) at 2012-10-20 19:06 CST
^Cpm@debian:~$ sudo nmap -sS www.google.com

Starting Nmap 6.00 ( http://nmap.org ) at 2012-10-20 19:06 CST
Nmap scan report for www.google.com (74.125.128.147)
Host is up (0.074s latency).
Other addresses for www.google.com (not scanned): 74.125.128.106 74.125.128.105 74.125.128.104 74.125.128.103 74.125.128.99
rDNS record for 74.125.128.147: hg-in-f147.1e100.net
Not shown: 998 filtered ports
PORT STATE SERVICE
80/tcp open http
443/tcp open https

Nmap done: 1 IP address (1 host up) scanned in 9.72 seconds

发表在 OS | 留下评论

记一次乌龙

上周做了个很乌龙的事情,我本来是想
[bash]
dd if=debian-xxx.iso of=/dev/sdb bs=1 count=1024
[/bash]
结果敲成成
[bash]
dd if=debian-xxx.iso of=/dev/sda bs=1 count=1024
[/bash]
等到我反映过来的时候已经写入了二三十兆了。我知道重启后肯定启动不起来了,毕竟分区表也坏了,就接了一个移动硬盘把重要的数据都放进去了。
之前不知道可以安装一个testdisk就能根据/proc/partitions来恢复分区表,至少能让重要的数据都不丢,大不了重装一下windows。
所以我把数据备份了一下就直接把全盘重新分区安装Debian了,装到最后发现无论如何安装不上GRUB2.重启也进入不了GRUB,就用U盘启动进入rescue模式,
chroot到了硬盘上,仔细看了一下grub-install /dev/sda后的报错
[bash]
/dev/sda appears to contain a iso9660 filesystem which isn’t known to reserve space for DOS-style boot. Installing GRUB there could result in FILESYSTEM DESTRUCTION if valuable data is overwritten by grub-setup (–skip-fs-probe disables this check, use at your own risk)
[/bash]
幸好后来google了一下,搜到了一个类似的文章1文章2。然后就照着
dd if=/dev/zero of=/dev/sda bs=512 seek=1 count=2047
然后就能把GRUB安装上了。

发表在 Admin | 留下评论

debian下初试lxc

现在容器型的虚拟化也很流行了,主要是相对XEN,KVM之类的能节省资源一些,这两天事情不是太多就简单了一下。
主要参考了debian的wiki(http://wiki.debian.org/LXC).我不是太喜欢把自己用的电脑搞一堆实验性的配置,所以就在virtualbox里面装了一个debian做宿主机再进行的,virtualbox使用的是桥接模式。
1.宿主机里面配置了一个网桥
/etc/network/interfaces
#allow-hotplug eth0
#iface eth0 inet dhcp

auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_fd 0
bridge_maxwait 0

然后重启网络
root@linux:~# ifconfig
br0 Link encap:Ethernet HWaddr 08:00:27:d2:35:1d
inet addr:192.168.2.207 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fed2:351d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:58 errors:0 dropped:0 overruns:0 frame:0
TX packets:59 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:7430 (7.2 KiB) TX bytes:7406 (7.2 KiB)

eth0 Link encap:Ethernet HWaddr 08:00:27:d2:35:1d
inet6 addr: fe80::a00:27ff:fed2:351d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:65 errors:0 dropped:0 overruns:0 frame:0
TX packets:65 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8662 (8.4 KiB) TX bytes:7874 (7.6 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 B) TX bytes:560 (560.0 B)

root@linux:~# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.080027d2351d no eth0

2.宿主机安装基础的软件和配置
2.1 安装 lxc bridge-utils libvirt-bin debootstrap
aptitude install lxc bridge-utils libvirt-bin debootstrap
2.2 /etc/fstab 添加
cgroup /sys/fs/cgroup cgroup defaults 0 0
2.3 拷贝一份模板
cp -a /usr/lib/lxc/templates/lxc-debian /usr/lib/lxc/templates/lxc-squeeze
并把/usr/lib/lxc/templates/lxc-squeeze里面的 lenny替换为squeeze,把dhcp-client替换为isc-dhcp-client

新建/etc/lxc/lxc1.conf 加入自己自定义一些配置
lxc.network.type=veth
lxc.network.link=br0 #这个要和自己建立的网桥的名字一致
lxc.network.flags=up
lxc.network.name = eth0
lxc.cgroup.cpuset.cpus = 0
#lxc.network.ipv4=192.168.2.150/24
3. 创建容器并启动
3.1 创建容器
lxc-create -n lxc1 /etc/lxc/lxc1.conf -t squeeze
3.2 启动容器
lxc-start -n lxc1

启动之后我们可以brctl show看看

root@linux:~# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.080027d2351d no eth0
vethyXMqY8
root@linux:~# ifconfig
br0 Link encap:Ethernet HWaddr 08:00:27:d2:35:1d
inet addr:192.168.2.207 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fed2:351d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:525 errors:0 dropped:0 overruns:0 frame:0
TX packets:314 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:45074 (44.0 KiB) TX bytes:50956 (49.7 KiB)

eth0 Link encap:Ethernet HWaddr 08:00:27:d2:35:1d
inet6 addr: fe80::a00:27ff:fed2:351d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:531 errors:0 dropped:0 overruns:0 frame:0
TX packets:331 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:51830 (50.6 KiB) TX bytes:53050 (51.8 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 B) TX bytes:560 (560.0 B)

vethyXMqY8 Link encap:Ethernet HWaddr 42:65:bf:83:0a:f8
inet6 addr: fe80::4065:bfff:fe83:af8/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:9 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1368 (1.3 KiB) TX bytes:1508 (1.4 KiB)

是br0下新增了一个网卡。

发表在 OS | 留下评论

perl使用非标准路径安装的cpan模块

cpanm支持安装模块的时候临时直接制定一个路径,对于没有root权限的人来说是比较方面的。
curl -LO http://bit.ly/cpanm
chmox +x cpanm
cp cpanm /usr/sbin

然后直接cpanm http://mirrors.163.com/cpan/authors/id/S/SA/SALVA/Net-OpenSSH-0.58_04.tar.gz ~/cpanlib/
就OK了。

但是在写脚本的时候要在BEGIN阶段把这个目录添加到@INC里。类似:
BEGIN { unshift @INC, ‘/home/pm/cpanlib/lib/perl5/’ }

这样就可以直接先用自己安装的新版本的模块,而不是用系统里带的老版本的模块了。

发表在 System | 留下评论

Net::OpenSSH的一个bug

因为想使用Net:OpenSSH的时候能forward_agent,就测试了一下最新版本的Net::OpenSSH.结果比较杯具的是发现forward_agent参数指定后不顶用。
仔细看了一下模块的代码,作者貌似是犯了一个比较低级的错误。有2处是
if ($self->{_forward_agent}) {
my $forward_agent = delete $opts{forward_agent};
push @ssh_opts, ($forward_agent ? ‘-A’ : ‘-a’) if defined $forward_agent;
}
这里实际是如果输入的时候定义了forward_agent就给ssh_opts加一个-A,表示开启转发。但是作者却还是从$opts{forward_agent}里面取。实际上第一次这样取值后,这个就被delete掉了。
我直接改了一下代码,patch如下
pm@debian:~$ cat OpenSSH.diff
1160,1162c1160,1161
< if ($self->{_forward_agent}) {
< my $forward_agent = delete $opts{forward_agent}; < push @ssh_opts, ($forward_agent ? '-A' : '-a') if defined $forward_agent; --- > if (defined $self->{_forward_agent}) {
> push @ssh_opts, ($self->{_forward_agent} ? ‘-A’ : ‘-a’);
1294,1296c1293,1294
< if ($self->{_forward_agent}) {
< my $forward_agent = delete $opts{forward_agent}; < push @ssh_opts, ($forward_agent ? '-A' : '-a') if defined $forward_agent; --- > if (defined $self->{_forward_agent}) {
> push @ssh_opts, ($self->{_forward_agent} ? ‘-A’ : ‘-a’);

修改后终于OK了。

================
UPDATE:
和模块的作者联系过,模块没有bug,只是使用的时候需要直接传入参数

my $out=$ssh->capture({“forward_agent” => 1},$cmd);

发表在 System | 留下评论

局域网bt tracker服务器配置

因为facebook使用bt分发应用包提高部署的速度,所以大家都在想能不能只用用现有开发成熟的软件做一个类似的方案出来。
自己简单地测试了一下,凑合可以用。不过bt的客户端很难找到一个合适的,transmission本来还不错的,但是细节的使用还是需要多搞一下。
昨天简单地用opentracker和ctorrent来测试了一下,基本能跑起来。

1.先设置单个的tracker服务器
直接找了一个开源的tracker服务器 http://erdgeist.org/arts/software/opentracker/。对照里面的readme就可以完成安装,

cvs -d :pserver:cvs@cvs.fefe.de:/cvs -z9 co libowfat
cd libowfat
make
cd ..
cvs -d:pserver:anoncvs@cvs.erdgeist.org:/home/cvsroot co opentracker
cd opentracker
make
我是把opentracker安装到了/opt目录下面。然后直接用命令启动 就行了

/opt/opentracker/bin/opentracker -p 6969 -P 6969 -d /opt/opentracker/run/ -u nobody &

2.使用mktorrent创建torrent(ctorrent其实也能建立种子但是测试了一下不支持目录)

根据单个文件制作种子的时候最好写绝对路径,简单测试一下把centos的一个镜像(CentOS-6.3-x86_64-LiveCD.iso )添加到种子里面。
$ mktorrent -a http://xxx.test1.net:6969/announce -o centos.torrent /home/admin/CentOS-6.3-x86_64-LiveCD.iso
mktorrent 1.0 (c) 2007, 2009 Emil Renner Berthing

Hashed 2768 of 2768 pieces.
Writing metainfo file… done.
类似根据目录添加到种子文件就是
mktorrent -a http://xxx.test1.net:6969/announce -o test2.torrent /home/admin/path_to_dir

在做种的服务器上直接提交种子
ctorrent centos.torrent
文件校验完成后就开始做种。

3.把种子文件拷贝到需要传输的几个机器上,然后在每台服务器上运行
ctorrent centos.torrent -s p2p/centos.iso
就会把文件下载到p2p目录下,并把文件存为centos.iso
简单测试了一下,把一个服务器上的文件删除后,可以看到另外一个服务器的在做种了,第一次上传了349M,第二次430M,还可以。局域网这样传输的速度非常的快。
Listening on 0.0.0.0:2705
\ 2/0/3 [2751/2768/2768] 688MB,0MB | 88078,0K/s | 81920,0K E:0,1
Download complete.
Total time used: 0 minutes.
Seed for other 72 hours.

\ 0/0/3 [2768/2768/2768] 692MB,349MB | 0,0K/s | 0,0K E:0,2
/ 0/0/3 [2768/2768/2768] 692MB,779MB | 0,0K/s | 0,0K E:0,2

后续: 这个只是简单测试了部署局域网内BT P2P分发的可行性,实际上很多细节的地方需要考虑。比如tracker服务器的精细化、集群化配置,opentracker感觉还是非常粗糙的一个东西,可以设置的地方很少,而且也没有后台页面查看。另外ctorrent虽然简单用用还行,但是几千台服务器还是要客户端能后台执行,命令行远程进行种子的添加(或者自动添加某个目录下的种子)、删除、任务完成后进行通知。transmission目前看来还可以,但是在N个版本的OS上安装就比较麻烦。

发表在 System | 留下评论

tar解压压缩包内的指定文件

最近有老的机房下线了,为了提高日志备份的速度,我就把每个应用下的日志目录整体打包压缩了。
但是这样又带来了一个新的问题,那就是经常会有人来找我提取日志查看,我地根据每个人的需求把日志解压出来。
因为日志存在一个存储上面,直接全部解压的话实际上会有很大的网络流量(log.tgz)NAS–>unzip server –>NAS(log)。
所以就写了个脚本只把每个应用下的指定日志解压出来
[bash]
#!/bin/bash
#############################
#
#Author: GNUer
#############################
LOGDIR=/mnt/abcvm/abcvm/app
APP=$1
LOGNAME="$2"
APPLOG=$LOGDIR/$APP/
usage(){
echo -e "usage:\n"
echo -e "\t$0 APP LOGNAME"
exit 0
}
OLDDIR=$(pwd)
echo "unzip $APP $LOGNAME*"
getlogname(){
local app
local logname
app=$1
logname=$2
[ ! $app ] && exit 2
for tgz in $(find $LOGDIR/$APP -name "*.tgz")
do

dir=${tgz%/*.tgz}
cd $dir
echo "unzip $tgz –> $dir"
tar –wildcards -zxf $tgz "*$logname*"
done
cd $OLDDIR

}
[ $# -ne 2 ] && usage
getlogname $APP $LOGNAME

[/bash]

发表在 Script, System | 留下评论

debian cpufreq配置

x220在windows下的待机一直是非常好的,但是在debian下经常耗电非常快,而且很烫。因为gnome3下设置cpu频率的那个插件不能使用了。所以就直接修改一下配置文件。因为获取电池电量有点问题,所以就把那部分去掉了。
[text]

[General]
pidfile=/var/run/cpufreqd.pid
poll_interval=2
verbosity=4
#enable_remote=1
#remote_group=root
#定义一般模式 0.8G-2.3G ondemand
[/General]
[Profile]
name=ac_normal
minfreq=1000000
maxfreq=2300000
policy=ondemand
[/Profile]

#定义使用电池时的一般模式 0.8G-1.6G conservative
[Profile]
name=bat_normal
minfreq=800000
maxfreq=1600000
policy=conservative
#policy=ondemand

[/Profile]

#定义高性能模式
[Profile]
name=performance_high
minfreq=1600000
maxfreq=2300000
policy=performance
[/Profile]

#定义一般的节能模式
[Profile]
name=powersave_nor
minfreq=800000
maxfreq=1200000
policy=powersave
[/Profile]

#定义低电量时的省电模式
[Profile]
name=powersave_low
minfreq=800000
maxfreq=800000
policy=powersave
[/Profile]

[Profile]
name=Conservative High
minfreq=800000
maxfreq=2300000
policy=conservative
[/Profile]
##
# Basic states
##
# 接电源时普通模式,ondemand
[Rule]
name=AC_Rule
ac=on # (on/off)
profile=ac_normal
[/Rule]

#接电源时编译代码时的高性能模式
[Rule]
name=AC_make_Rule
ac=on
programs=cc1,cc1plus,make,gcc,g++
profile=performance_high
[/Rule]

#电池时使用普通的conservative,0.8-1.6G
[Rule]
name=normal_battery
ac=off # (on/off)
#battery_interval=60-100
profile=bat_normal
[/Rule]

# 中等电量时使用的节能模式
#[Rule]
#name=medium_battery
#ac=off # (on/off)
#battery_interval=0-60
#profile=powersave_nor
#[/Rule]
#
## 低电量时使用的节能模式
#[Rule]
#name=low_battery
#ac=off # (on/off)
#battery_interval=0-30
#profile=powersave_low
#[/Rule]

##
# Special Rules
##
#接通电源时,如果CPU太烫时改变为和用电池时用的conservative。
[Rule]
name=CPU Too Hot
ac=on
acpi_temperature=70-100
cpu_interval=70-100
profile=bat_normal
[/Rule]

[/text]

这样插上电源的时候使用 ondemand模式,cpu的频率设置为1g-2.3G,拔掉电源后使用 conservative,cpu的频率设置为0.8g-1.6g。
不过现在风扇设置好像还有点问题,需要继续配置一下thinkfan才行。

今天只是把thinkfan安装上了,增加了模块加载的参数
[text]
pm@debian:/etc/modprobe.d$ cat /etc/modprobe.d/thinkfan.conf
options thinkpad_acpi fan_control=1

[/text]
然后 /etc/thinkfan.conf里设置了sensor /sys/class/hwmon/hwmon0/temp1_input

发表在 Admin | 留下评论

shell版本的12306等待

看微博上大家在搞就搞了一个

#!/bin/bash
stty erase ^H 
hello(){
	echo -e "\e[1;31m欢迎使用铁路客运服务中心\e[m"
	echo "======================="
	echo  -e -n "\e[1;34m用户名:\e[m"
	read
	echo  -e -n "\e[1;34m密码:\e[m"
	stty -echo
	read
	stty echo
	echo -e "\n=======================\n"
}
wait_2m(){
	second=120
	length=240
	while [ $second -gt 0 ]
	do
		sleep 1;
		second=$((second -1 ))
		length=$((length -2 ))
		echo -e -n "\r您前面还有\e[1;32m$length\e[m人在等待,您还需要等待\e[32m$second\e[m秒"
	done
	echo -e  "\e[1;32m\n恭喜您,轮到您购票了!\e[m"
}
hello
wait_2m

运行示范

QQ截图20120918224631

发表在 linux shell | 留下评论