下面是 ‘脚本语言’ 的汇总

Solaris管理员常用命令

Friday, November 2nd, 2007

Solaris管理员常用命令,很多Solaris的命令跟Linux还是不太一样的,记录再次,仅供参考。

SysAdmin Commands

Debugging

truss executable
/* Trace doing of given command ( useful debugging ) */

truss -f -p
/* Using multiple windows, this can be used to trace setuid/setgid programs */

Arp, ethernet trouble shooting

arp -a .
/* Shows the ethernet address arp table */

arp -d myhost
/* Delete a stale ethernet entry for host myhost */

Disk Commands

du -k .
/* Reports disk space used in Kilobytes */

du -sk .
/* Reports only total disk space used in Kilobytes */

du -sk *|sort -k1,1n
/* Reports total disk space used in Kilobytes in present directory */

du -ad /var | sort -nr
/* Tells you how big the /var files are in reverse order */

fdformat -d -U
/* Format diskette */
(more…)

利用truss在Solaris下定位问题

Saturday, October 13th, 2007

在Solaris下面,如果需要跟踪系统的调用,以便查找和定位问题,truss是一个非常有用的命令,下面就对这个命令做详细介绍。

truss 命令
用途

跟踪进程的系统调用、动态装入的用户级函数调用、接收的信号和造成的机器故障。

语法

truss [ -f] [ -c] [ -a] [ -l ] [ -d ] [ -D ] [ -e] [ -i] [ { -t | -x} [!] Syscall […] ] [ -s [!] Signal […] ] [ { -m }[!] Fault […]] [ { -r | -w} [!] FileDescriptor […] ] [ { -u } [!]LibraryName […]:: [!]FunctionName [ … ] ] [ -o Outfile] {Command| -p pid [. . . .]}

描述
truss 命令执行指定命令或附加在列出进程标识上,并产生对系统调用、接收的信号和进程造成的机器故障的跟踪。每行跟踪输出报告 Fault 或 Signal 名称或 Syscall 名称和参数及返回值。系统库定义的子例程对于内核的严格系统调用并不是必要的。truss 命令不报告这些子例程,而是报告子例程的基本系统调用。 可能的话,系统调用参数使用有关系统头文件定义符号显示。对于路径名指针参数,truss 显示指向的字符串。未定义的系统调用缺省显示系统名称、所有八个可能的变量及十六进制格式的返回值。
(more…)

如何活学活用sed和awk

Friday, September 28th, 2007

sed和awk都是功能非常强大的流编辑器,如果能活学活用,常常可以节省很多时间,收到事半功倍的效果。

这里引用的两篇文章都不长,而且例子非常丰富,希望能对你有所帮助。

先说说awk:

Awk is an powerful command language that allows the user to manipulate files containing columns of data and strings. Awk is extremely useful, both for general operation of Unix commands, and for data reduction (e.g. IRAF). You might also learn how to use the stream editor sed. Many applications of awk resemble those done on PC spreadsheets.

This file contains a number of examples of how to use awk. I have compiled this table gradually over a couple of years as I’ve learned to do new things. Everyone who reduces data with IRAF should learn the fundamentals of AWK Learning to do even simple things will save you a lot of time in the long run. It should take you less than an hour to read through this file and learn the basics.

There are two ways to run awk. A simple awk command can be run from a single command line. More complex awk scripts should be written to a command file. I present examples of both types of input below.
(more…)

利用sed批量替换一批文件

Tuesday, August 21st, 2007

在需要对一个文件进行替换的时候,利用sed这个工具非常有用,比如

sed ’s/abc/efg/g’ file

今天遇到一目录的文件需要批量进行替换,这样就比较麻烦了。以前还没有这样做过。man了一下sed的帮助,又从网上查找了一下,发现了一个比较好的解决方案,用参数-in-place。

在Linux平台上,利用如下命令即可达成:

sed -in-place -e ’s/abc/cba/g’ *

不过好像Solaris平台不支持-in-place这个参数,只能用一个小小的程序实现了。

for f in `ls *.html`
do
cat $f | sed s#/style.css#/blog/styles_zh-cn.css#g > tmp.txt
mv -f tmp.txt $f
done

本文参考了车东的一片帖子

利用批处理文件修改DNS

Tuesday, June 26th, 2007

我有的时候会把公司做不完的事情带回家,在家通过网络写点脚本,做点事情。
家里的网络用的是深圳聚友网络,当初贪图便宜,没想到便宜没好货,网速距慢,而且三天两头修改配置。

麻烦就麻烦在这配置上,每次在家上网,都需要首先修改DNS为一个固定的DNS服务器。然后登录帐号密码方可上网。但是在公司,就没有这么繁琐,直接接上网线即可,所以需要把DNS取消掉,改为自动从DHCP服务器获取。

修改DNS虽说不是很麻烦,不过有的时候总记不得。所以干脆写了一个批处理脚本。Windows提供了一个netsh,可以在命令行下进行IP地址或者DNS的设置。下面对此作简单介绍,然后show一下我的简单的批处理脚本。
(more…)

Solaris管理员常用命令

Friday, May 25th, 2007

整理文档的时候发现的这篇文档,家庭常备,备用。

前面是命令,后面/* */中的是解释。

truss executable
/* Trace doing of given command ( useful debugging ) */
truss -f -p /* Using multiple windows, this can be used to trace setuid/setgid programs */
Arp, ethernet trouble shooting
arp -a .
/* Shows the ethernet address arp table */
arp -d myhost
/* Delete a stale ethernet entry for host myhost */
(more…)

TCL访问Oracle的扩展包-Oratcl

Friday, May 25th, 2007

前阵子,用TCL开发了一个类似QTP的东东,我叫他基于ORACLE的QTP,在部署的时候,需要安装在Linux服务器上,并且对服务器有一定的要求,比如:
1 必须安装TCL
2 必须安装ORACLE的客户端程序
3 必须安装TCL访问Oracle的扩展包-Oratcl

我在一台新安装的服务器上(REL4)进行部署的时候,捣鼓了两天,没有搞定,郁闷死了,不过还是有些收获,下面说说过程。

首先说下背景,这台Linux上的TCL版本是8.3,因为是别人安装,所以Oracle9的客户端安装可能有些问题。另外,Oratcl并没有安装,噩梦就从这个包的安装开始。
(more…)

Linux下的有趣命令

Friday, May 18th, 2007

转载的:来自水木讨论,总结一下。有些是搞笑的,有些也还是很有用的:

yes:输出一串y,有时可以用来对付很多y/n选择的应用
banner:打印字符标题,就是用字符拼出大字来【这个没有弄出来】
ddate:把日历转成什么其他历,Today is Sweetmorn, the 63rd day of Discord in the YOLD 3173
fortune:输出一句话,内容有很多种,据说有唐诗宋词【可能需要安装】
cal 9 1752:打印日历,不过那一个月的有问题,哈,还有个ccal有农历的不知道怎么样了【农历的弄不出来】

cal 9 1752是有历史原因的,以下内容摘自wikipedia
格里历1582年10月15日,合儒略历1582年10月5日,只有意大利、波兰、西班牙、葡萄牙开始用格里历,日期跳过10日。由于新历法是教皇颁布的,新教国家予以抵制。直到18世纪,大英帝国,包括英格兰、苏格兰、以及现在美国的一部份才采纳格里历,也就是儒略历1752年9月2日星期三的次日是格里历1752年9月14日星期四,日期跳过11日。

tac:concatenate and print files in reverse,把文件的行反过来打印
ptx - produce a permuted index of file contents,生成索引?不知道
xev:打印即时的X事件【没弄出来,需要X11吧】
xeyes:出眼睛那个,进X第一都要玩玩吧【需要X11吧】
cowsay/cowthink:打印一个小牛(或其他动物)说话或想像,内容可自定【没弄出来】
factor:分解因数
shred:覆盖文件让它不能再读
aptitude moo/apt-get moo -vvvvv:debian搞笑的
还有make love,翻成中文倒不好玩了
还有人说who am i,不够有意思
有人说 rm -fr /,还有dd if=/dev/zero of=/dev/mem,这就太坏了,没事别试,尤其是root敢死队不要试
csmash:一个3d乒乓游戏,没玩过。【没弄出来】


Close
E-mail It