About 4Aiur

Posts by 4Aiur:

利用xargs实现多任务并发

Posted by 4Aiur on 04/06/2010 in Shell |

利用xargs实现多任务并发

[4aiur@localhost Temp]$ echo 127.0.0.1 192.168.2.50 192.168.10.108 | xargs -n1 -P2 -I % ping -c 3 %
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.048 ms
PING 192.168.2.50 (192.168.2.50): 56 data bytes
64 bytes from 192.168.2.50: icmp_seq=0 ttl=64 time=0.026 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.091 ms
64 bytes from 192.168.2.50: icmp_seq=1 ttl=64 time=0.022 ms
64 bytes from 192.168.2.50: icmp_seq=2 ttl=64 time=0.039 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.077 ms

--- 192.168.2.50 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.022/0.029/0.039/0.007 ms

--- 127.0.0.1 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.048/0.072/0.091/0.018 ms
PING 192.168.10.108 (192.168.10.108): 56 data bytes
64 bytes from 192.168.10.108: icmp_seq=0 ttl=63 time=6.244 ms
64 bytes from 192.168.10.108: icmp_seq=1 ttl=63 time=1.392 ms
64 bytes from 192.168.10.108: icmp_seq=2 ttl=63 time=1.062 ms

--- 192.168.10.108 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 1.062/2.899/6.244/2.369 ms
[4aiur@localhost Temp]$

使用xargs扫描同网段内存活的设备

[4aiur@localhost Temp]$ for ((x=1; x/dev/null | awk /ttl/'{print $4}'

Tags:

Show File System Hierarchy

Posted by 4Aiur on 04/06/2010 in BSD, Linux |

Show File System Hierarchy $ man hier Curious about differences between /bin, /usr/bin, and /usr/local/bin? What should be in the /sbin dir? Try this command to find out. Tested against Red Hat & OS X

Tags:

目录名大小写转换

Posted by 4Aiur on 04/06/2010 in Shell |

使用find把目录名修改为大写——- find . -type d | sort -r |\ while read name do echo “mv $name ${name%/*}/echo ${name##*/} | tr '[:lower:]' '[:upper:]'” mv $name ${name%/*}/echo ${name##*/} | tr '[:lower:]' '[:upper:]' done 使用递归方式把目录名修改为小写 #!/bin/bash # set -x tolower () { ls | while read name do if [ -d $name ] ; then new_name=echo $name | […]

Tags:

定制MacOSX ls颜色

Posted by 4Aiur on 04/06/2010 in BSD |

定制MacOSX ls颜色 习惯了linux的ls颜色,不适应MacOSX终端中的ls颜色修改了ls颜色使用的默认环境变量,跟linux有些接近了。 首先增加一个 aliasalias ll=’ls -lG’ 之后修改LSCOLORS环境变量 export LSCOLORS=ExGxCxDxCxEgEdAbAgAcAd LSCOLORS from man ls: LSCOLORS The value of this variable describes what color to use for which attribute when colors are enabled with CLICOLOR. This string is a concatenation of pairs of the format fb, where f is the fore- ground color and b is […]

Tags:

使用多种方法打印50个连续的横杠

Posted by 4Aiur on 04/06/2010 in SysAdmin |

使用多种方法打印50个连续的横杠 python -c ‘print “-” * 50′ perl -le’print”-“x50’ awk ‘BEGIN{while (a++

Tags:

perl发送邮件注意事项

Posted by 4Aiur on 04/06/2010 in Perl |

perl发送邮件注意事项 1) 程序手工执行可以发送mail,而把程序加入到crontab后无法执行的解决方法在crontab中执行脚本前,加入. /etc/profile; 0 * * * * * . /etc/profile ; /usr/bin/perl /app_path/mail.pl >/dev/null 2>&1 2) smtp服务器需要认证,而Net::SMTP的auth方法不起作用的解决方法Net::SMTP的auth方法依赖Authen::SASL这个模块, 可以用perl -e 'use Authen::SASL'试试,看下是否报错,如果报错的话需要安装Authen::SASL模块。 安装方法: # perl -MCPAN -e ‘install Authen::SASL’ 顺便提一下,用抓包工具看的话smtp认证过程账户和密码部分是乱码,其实可以转换出来,乱码的unicode是base64,使用python的decode方法可以转换出明文。 >>> s=’string’ >>> s.encode(‘base64’) ‘c3RyaW5n\n’ >>> u=u’c3RyaW5n\n’ >>> u.decode(‘base64’) ‘string’ >>> unicode的问题在RFC 2554中有所描述。 附代码: #!/usr/bin/perl use strict; use warnings; use Net::SMTP; my $mailhost=’mail.example.com’; #Mail […]

Tags:

摘自www.commandlinefu.com的一些命令

Posted by 4Aiur on 04/06/2010 in Shell |

摘自www.commandlinefu.com的一些命令 # change to the previous working directory $ cd – # quickly backup or copy a file with bash $ cp filename{,.bak} # mtr, better than traceroute and ping combined # mtr combines the functionality of the traceroute and ping programs in a single network diagnostic tool. # As mtr starts, it investigates the […]

Tags:

使用Python解析Excel

Posted by 4Aiur on 04/06/2010 in Python |

使用Python解析Excel 解析Excel文件常用的module有pyExcelerator与xlrd,目前这两个模块只能支持excel2004以下版本生成的文件。 我写了一个从excel文件读取工资,并给员工发送工资条邮件的程序放在了github上,里面有一些解析excel文件细节的代码,有兴趣的同学可以下回去看看。 代码存放地址: https://github.com/mlf4aiur/payslip pyExcelerator范例 查看pyExcelerator的tools中xls2txt.py了解到pyExcelerator使用parse_xls方法解析excel文件。 调用parse_xls方法后,生成的结果为list,list的结构示例如下: [(u’Sheet1′, {(0, 0): 111, (0, 1): 112, (1, 0): 121, (1, 1): 122}), (u’Sheet2′, {(0, 0): 211, (0, 1): 212, (1, 0): 221, (1, 1): 222}), (u’Sheet3′, {})] 安装pyExcelerator sudo pip install pyExcelerator localhost:Share 4aiur$ ipython Leopard libedit detected. Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51) Type […]

Tags: ,

FreeBSD内存文件系统

Posted by 4Aiur on 04/06/2010 in BSD |

FreeBSD内存文件系统 [4aiur@FreeBSD ~/memeory_fs]$ sudo mount -t tmpfs -o size=1m tmpfs tmpfs/ [4aiur@FreeBSD ~/memeory_fs]$ sudo mdmfs -s 1m md mfs [4aiur@FreeBSD ~/memeory_fs]$ df -h tmpfs/ mfs/ Filesystem Size Used Avail Capacity Mounted on tmpfs 648M 4.0K 648M 0% /usr/home/4aiur/memeory_fs/tmpfs /dev/md5 846K 4.0K 776K 1% /usr/home/4aiur/memeory_fs/mfs

Tags:

安装好FreeBSD后的一些基础配置修改

Posted by 4Aiur on 04/06/2010 in BSD |

安装好FreeBSD后的一些基础配置修改 配置alias [root@FreeBSD ~]# alias alias cp=’cp -i’ alias grep=’grep –color’ alias ll=’ls -lG’ alias mv=’mv -i’ alias rm=’rm -i’ alias vi=’vim’ [root@FreeBSD ~]# 安装sudo [root@FreeBSD ~]# cd /usr/ports/security/sudo [root@FreeBSD /usr/ports/security/sudo]# make [root@FreeBSD /usr/ports/security/sudo]# make install [root@FreeBSD /usr/ports/security/sudo]# make clean 修改man的环境变量,使用less来查看手册 FreeBSD -P pager Specify which pager to use. By default, man uses “more -s”. […]

Tags:

Copyright © 2010-2024 4Aiur All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.