162011

部分服务器使用单独的key,为了方便,写了这2个脚本

2个版本,都需要Python
Windows版
win_crt_conf.py

cygwin版
cygwin_crt_conf.py

cygwin下可以用find+sed+unix2dos实现,但真的太慢了,Python快啊

2个文件要修改的地方是一样的

需要使用单独key的SecureCRT配置文件目录
crt_conf_dir = 'E:\\CRT_CONF'

定义key文件的位置,identify为private key的名字
key_path_new = 'S:"Identity Filename"=E:\CRT_KEY\identify'

原理,每个服务器配置都定义了使用全局key还是会话key
这个是使用全局key
D:"Use Global Public Key"=00000001
定义使用的key文件路径
S:"Identity Filename"=

定义使用会话key
D:"Use Global Public Key"=00000000

E:\CRT_KEY\identify为要使用的会话key
S:"Identity Filename"=E:\CRT_KEY\identify
win_crt_conf.py

#!D:\\Python27\\python
#-*-coding=utf-8-*-    

import os,sys,re  

crt_conf_dir = 'E:\\CRT_CONF'
global_public_key_true = 'D:"Use Global Public Key"=00000001'
global_public_key_false = 'D:"Use Global Public Key"=00000000'
key_path_old = 'S:"Identity Filename"='
key_path_new = 'S:"Identity Filename"=E:\CRT_KEY\identify'

re_global_public_key = re.compile(global_public_key_true,re.DOTALL)
re_key_path = re.compile('S:"Identity Filename"=(.*)')

os.chdir(crt_conf_dir)  

c1 = os.walk(os.getcwd()) 

filelist = []   

for c2 in c1:
	for c3 in c2[2]:
		filelist.append(os.path.join(c2[0],c3))

for filename in filelist:
    fileread = open(filename,'r')
    filer = fileread.read()
    pub_key = re.sub(re_global_public_key,global_public_key_false,filer,0)
    key_path = re.sub(re_key_path,key_path_new,pub_key,0)
    fileread.close()
    fileok = open(filename,'w')
    fileok.write(key_path)
    fileok.close()
    print filename,'替换成功!'

cygwin_crt_conf.py

#!/usr/bin/python
#-*-coding=utf-8-*-    

import os,sys,re  

crt_conf_dir = '/cygdrive/e/CRT_CONF'
global_public_key_true = 'D:"Use Global Public Key"=00000001'
global_public_key_false = 'D:"Use Global Public Key"=00000000'
key_path_old = 'S:"Identity Filename"='
key_path_new = 'S:"Identity Filename"=E:\CRT_KEY\identify'

re_global_public_key = re.compile(global_public_key_true,re.DOTALL)
re_key_path = re.compile('S:"Identity Filename"=(.*)')

os.chdir(crt_conf_dir)  

c1 = os.walk(os.getcwd()) 

filelist = []   

for c2 in c1:
	for c3 in c2[2]:
		filelist.append(os.path.join(c2[0],c3))

for filename in filelist:
    fileread = open(filename,'r')
    filer = fileread.read()
    pub_key = re.sub(re_global_public_key,global_public_key_false,filer,0)
    key_path = re.sub(re_key_path,key_path_new,pub_key,0)
    fileread.close()
    fileok = open(filename,'w')
    fileok.write(key_path)
    fileok.close()
    print filename,'Replace successful!'

主要参考了http://blog.591by.com/show-214-1

Posted by admin
032011

1、学习Python处理中文的方法
2、学习正则表达式

#!D:\\Python27\\python
#coding=gbk

"""System : Windows 7"""

import subprocess
import re
import sys
print "ping "+sys.argv[2]+"次 "+sys.argv[1]

##设置为unicode编码
p = re.compile(u'(\W\W = \d+ms)')
out = subprocess.Popen("ping -n %d %s" % (int(sys.argv[2]),sys.argv[1]),stdout=subprocess.PIPE,shell=True)

#将gbk编码的输出解码为unicode,并查找关键字
match = p.findall(out.stdout.read().decode("gbk"))

for result in match:
    print result
Posted by admin
282010

通过本文制作出来的U盘,实现以下系统的启动
1、 Ubuntu_10.10-x86_64_Live,并可以保存系统修改后的配置
2、 小马PE101010—功能非常齐全
3、 CDlinux社区标准版+无线破解
4、 Ubuntu_10.10_64_fast,能快速启动,但配置不能保存,这里主要演示下grub4dos可以直接挂载iso文件

4GU盘一个,越大越好,我的是:
Verbatim STORE N GO 4G

用到的软件
BOOTICE –用于安装grub4dos

Linux下的操作
为使Ubuntu系统的配置能够保存,我们需要创建一个卷标为casper-rw的分区
登录进Linux系统,对U盘进行分区,这里我创建了一个1G的分区用于保存Ubuntu系统的配置,分区的大小,主要是看你要安装的软件和保存文件的大小,空间越大,能够保存的配置就越多,我主要是安装了中文语言文件和一个浏览器。

这里,我的系统识别到U盘是/dev/sdb

fdisk /dev/sdb
如何分区,可以Google下,有个小提示是,fdisk分区时,是根据柱面来分的,1个柱面约等于8M的空间

格式化/dev/sdb2
mkfs.ext2 /dev/sdb2

设置/dev/sdb2的卷标
e2label /dev/sdb2 casper-rw

Windows下的操作
打开BOOTICE,选择U盘

这里有2种引导记录
主引导记录—针对只有1个分区的U盘或者移动硬盘
分区引导记录—针对有几个分区的U盘或者移动硬盘
由于我们对U盘进行了分区,所以,这里选择“分区引导记录”

选择第一个分区,默认选的就是 GRUB4DOS,点击“安装/配置”
弹出的对话框,直接点击“确定”即可

这时,U盘就是可启动的了
编写启动菜单文件menu.lst, 并放到U盘根目录,注意,kernel哪里都是一行的

timeout 30
default 0
gfxmenu /BOOT/message
title [01] Ubuntu_10.10-x86_64_Live
find --set-root /casper/vmlinuz
kernel /casper/vmlinuz boot=casper persistent file=/preseed/ubuntu.seed looptype=squashfs loop=/casper/filesystem.squashfs
initrd /casper/initrd.lz
title [02] 小马PE
find --set-root /WXPE/SETUPLDR.BIN
chainloader /WXPE/SETUPLDR.BIN (hd0)+1
title [03] 启动CDlinux社区标准版+无线破解
find --set-root /CDlinux/bzImage
kernel /CDlinux/bzImage quiet CDL_LANG=zh_CN.UTF-8 CDL_AMOUNT=yes
initrd /CDlinux/initrd
title [04] Ubuntu_10.10_64_fast
map (hd0,0)/Ubuntu_10.10_64.iso (hd32)
map --hook
root (hd0,0)
kernel (hd32)/casper/vmlinuz boot=casper iso-scan/filename=/Ubuntu_10.10_64.iso
initrd (hd32)/casper/initrd.lz
title [F9] 重启计算机
reboot
title [F10] 关闭计算机
halt

用虚拟光驱加载Ubuntu的镜像,把整个ISO的文件内容拷贝到U盘,这时,Ubuntu就准备好了

xmpe101010介绍

http://bbs.wuyou.com/viewthread.php?tid=168287

下载地址

http://u.115.com/file/t5e0236d5f

同样用虚拟光驱加载小马PE的文件,把minipe的文件拷贝到U盘根目录下,同时把wxpe目录下的ntdetect.exe拷到U盘根目录下,至此,小马PE就准备好了

CDlinux社区标准版+无线破解,我们需要从另外一个镜像里提取

无忧启动.多功能维护工具盘(无线破解).iso
下载地址:

http://u.115.com/file/t21e955d0a

同样用虚拟光驱加载无忧启动.多功能维护工具盘(无线破解).iso,在U盘根目录下建个boot目录,然后把ISO里的BOOT目录下的message拷贝到U盘的boot下,这个主要是用来美化菜单的
把iso里的CDlinux拷贝到U盘根目录下

把Ubuntu 10.10 64位的iso拷贝到U盘根目录下,Ubuntu的快速启动也准备好了,现在可以用U盘启动

扩展阅读
这里顺便说明下,其实用dd命令生成一个虚拟硬盘文件放到U盘,然后对该文件进行格式化也是可以的,但我自己制作的时候,Ubuntu无法启动,所以还是采用分区的方法,写下方法生成虚拟磁盘文件的方法
参考这篇文章

http://hi.baidu.com/cnjowang/blog/item/b58734869d5c6226c65cc3ea.html

dd if=/dev/zero of=casper-rw bs=1M count=1024
mkfs.ext2 -F casper-rw

Ubuntu的配置是否保存,关键看kernel行是否使用了persistent

已知问题:
CDlinux在部分机器无法启动

主要参考文章:

http://forum.ubuntu.org.cn/viewtopic.php?t=172013

Posted by admin Tagged with:
262010

最近买了个蓝牙鼠标,动不动就无响应,非常不爽,
右键我的电脑--管理--Bluetooth无线电收发器,右键你的蓝牙设备,选择属性,再点电源管理,把允许计算机关闭此设备以节约电源前的勾去掉

Win 7,到处都是省电的配置,低碳?

也有人说是驱动问题:
去下个这个驱动应该可以解决 IVT_BlueSoleil_5.0_for_32bit_OS
我用的是32位的。如果你是64位就不知道下64位能解不了.......

参考文章

http://bbs.pcbeta.com/archiver/tid-580570.html

Posted by admin Tagged with:
052010

最近发现即使我在命令提示符输入powercfg -h on,开始菜单和电源选项还是没有休眠的按钮,折腾了一段时间,终于解决了问题,方法如下:首先就是众所周知的powercfg -h on,然后重启(这个很重要)。最后依次点击控制面板->硬件和声音->电源选项->更改计划->高级电源设置->睡眠,将“允许混合睡眠”设为“关闭”。

转载自:http://www.xuwemjian.info/archives/999.html

Posted by admin