在UNIX/Linux下查看某个进程的详细参数

如果要在UNIX/Linux下查看某个进程的详细参数, 可以用命令:

 

           ps -axuww|grep <process>

但需要注意的是,在Solaris下,存在两个版本的ps:一是/usr/bin/ps;一是/usr/bin/ps。只有/usr/bin/ps可以用于上述命令。

"/usr/ucb/ps" 是从BSD UNIX中继承而来的,而/usr/bin/ps从AT&T SVR4继承而来的。二者之间存在较大区别, 如果有些

参数在某个ps中不能应用,可以考虑换用另外一个。

 

 

本文参考了如下网页:

http://www.sunmanagers.org/pipermail/summaries/2006-March/007182.html

 

在美国体验猪流感

 


在美国体验猪流感


赴美之前,很多人就提醒我美国的猪流感正流行,而且我所要去的Illinois更是重灾区。我自己也很担心,尤其是当中国也有了猪流感疑似病例之后。

一进首都机场就已经感受到了人们的恐惧,很多中国人都带着口罩。因为考虑到需要坐12.5个小时的飞机,而且我相信在中国的外国人也应该没有收到感染,因此我就没有戴口罩(其实是拿了两个的,放在包里一直没有拿出来)。
在飞机上,发现坐我后面的一个哥们一直带着口罩,睡觉的时候都没有摘下来,实在是太佩服他的耐心了。同时我发现没有一个外国人戴口罩。 来到芝加哥下了飞机,入海关,直到出了机场,又在机场外面等了同事一个小时,也没有发现一个人戴口罩——即使是原来戴口罩的中国人,也不得不把口罩摘了下来,因为没人戴口罩。可以想见,如果谁胆敢带着口罩入海关,搞不好会被海关大叔/大婶给盘问甚至reject的——海关人员都是很拽的样子。
昨晚在 一个同事的带领下去了Naperville的一个小教堂进行Church Talk(美国退休的老头老太太自愿在教堂工作,每天晚上和外国人交谈是他们工作的一部分,叫做Church Talk;话题可以海阔天空,不限于宗教,尽管他们和你谈话的最终目的是希望你入教,但绝大多数中国人去那里的最初目的是练口语)。几个老头老太太一见到我得知我是刚刚从中国来的,就问我中国人怎么看美国的猪流感?为什么那么多中国人如此的害怕美国的猪流感?我说几年前中国刚刚经历过一场SARS,很多人在那场瘟疫中死掉了。中国人现在对猪流感心存忌惮也是有情可原的。而出乎我的预料的是,几个老头竟然告诉我只要勤洗手和保持充足的睡眠,猪流感是完全不必担心的。这些我在国内的时候就知道,但是在几个美国老头的口中说出,仍让我很诧异:连这样的匹夫匹妇对于猪流感的认识都如此轻松,美国人的自信以及新闻媒体在美国的重要性可见一斑。

 

近期遇到的几个Solaris 10 的问题

公司正在逐渐把server升级为Solaris 10, 对于新平台我非常陌生(当然了,对于以前的Solaris 9也不怎么懂),遇到了几个值得记录下来的问题。

 

1. $HOME目录几乎所有文件(夹)的owner和group都被改为nobody

昨天在工作时遇到了问题,自己无法解决,求助于同事。同事帮忙查了半天,发现了我的$HOME下的所有的文件和文件夹的owner和group都被改为nobody了。我们都很诧异为什么会出现这种情况,求助于公司的IT,IT们说这是因为我们部门有两个NFS storage,其中一个和NFS的版本和Solaris 10兼容,另外一个不兼容。而我的$HOME恰好就在不兼容的Storage上,结果权限就变了。

 

今天上午IT把这个问题FIX了,但我对于NFS还是不清楚,对于权限如何变的也不知道。有时间再去仔细研究NFS的问题。

 

2. ld.so.1: cp:fatal: libsec.so.1: open failed: No such file or directory

ld.so.1: cp: fatal: libsec.so.1: version `SUNW_1.2' not found (required by file /usr/bin/cp)

 

这是一个动态链接库的问题。这个问题Google了一下发现很多人也有类似的问题,但没有看到如何解决。貌似

Sun推出了一个patch来解决这个问题。但具体情况不了解。

 

前几天早晨遇到了这个问题,和同事查了一上午也没发现原因,结果当我们绝望的时候这个问题自己消失了。莫名其妙。

但这个问题估计在往后系统重启以后还会发生。

破解“读心术”网页

 

无意之中看到这样一种网页“读心术:这个程序有着能够看穿你心思的特殊能力,试试吧”,如http://www.souxin.com/dxs.htm 或 http://www.91cool.net/heart.html

试过之后大感惊奇,该网页怎么竟有如此魔力?但我毕竟是个无神论者,而且用的又是Chrome浏览器,查看网页的源代码很方便,于是便查看网页源代码。找了半天,发现了相关的代码如下:
<SCRIPT language=javascript> 
ax=0;
function writeTable() {
        ax=Math.round(Math.random()*26);
        alphaArray=new Array("a", "n", "b", "d", "f", "h", "{", "i", "l", "v", "x", "z", "I", "J", "M", "N", "o", "O", "R", "S", "T", "U", "m", "6", "^", "u", "_", "[", "]")
        table="<table border=0 cellspacing=1 cellpadding=1 width='100%'><tr>"
        j=1;
        for ( i = 99 ; i >= 0 ; i-- ) {
                a=Math.round(Math.random()*26);
                if ( i%9 == 0 && i < 89 ) 
                        a=ax;
                table+="<td class='numtd'>"+i+"</td><td class='symtd'>"+alphaArray[a]+"</td>"
                 if ( j%10 == 0 ) 
                         table+="</tr><tr>" 
                 j++
        }
        table+="</table>"
        sym.innerHTML=table
        sh.innerHTML=""
}
function showAnswer() {
        sh.innerHTML=alphaArray[ax]
        sym.innerHTML="<span class=big><a href="javascript:writeTable()" mce_href="javascript:writeTable()" class=hot>Try Next 再试一次</a></font></span><br><br>"
}
</SCRIPT> 

 

看了又看也没发现这段代码有何神奇之处,无非就是打印输出表格,用到了随机数改变输出的图像顺序而已。

我忽然注意到了“ i < 89”这一条件,认定此处必有玄机。我于是算了一算,发现90~99所有的数按照“读心术”的要求运算之后都是81,而80~89运算之后都是72,70~79是63,以此类推分别是54、45、36、27、18和0.只要保证0、18、27、36、45、54、63、72、81这几个数所对应的图像是相同的就可以了。查看“读心术”网页打印出来的图像,果然如此。
继续看代码,发现了“i%9 == 0”这一判断条件,再一观察,发现上面那几个关键的数(0、18、27、36、45、54、63、72、81)确实是9的倍数。代码中当遇到小于89的9的倍数时,强制令a=ax,这样一来便保证了9的倍数对应的图像是相同的。于是,对于任何符合两位数,减去自己的个位和十位后,所对应的图像都是相同的。这就是所谓“读心术”程序的trick。

 

[转]在C语言中使用正则表达式

 

在C语言中使用正则表达式

如果用户熟悉Linux下的sed、awk、grep或vi,那么对正则表达式这一概念肯定不会陌生。由于它可以极大地简化处理字符串时的复杂度,因此现在已经在许多Linux实用工具中得到了应用。千万不要以为正则表达式只是Perl、Python、Bash等脚本语言的专利,作为C语言程序员,用户同样可以在自己的程序中运用正则表达式。  

标准的C和C++都不支持正则表达式,但有一些函数库可以辅助C/C++程序员完成这一功能,其中最著名的当数Philip Hazel的Perl-Compatible Regular Expression库,许多Linux发行版本都带有这个函数库。  

编译正则表达式  

为了提高效率,在将一个字符串与正则表达式进行比较之前,首先要用regcomp()函数对它进行编译,将其转化为regex_t结构:  

int regcomp(regex_t *preg, const char *regex, int cflags); 

参数regex是一个字符串,它代表将要被编译的正则表达式;参数preg指向一个声明为regex_t的数据结构,用来保存编译结果;参数cflags决定了正则表达式该如何被处理的细节。  

如果函数regcomp()执行成功,并且编译结果被正确填充到preg中后,函数将返回0,任何其它的返回结果都代表有某种错误产生。  

匹配正则表达式  

一旦用regcomp()函数成功地编译了正则表达式,接下来就可以调用regexec()函数完成模式匹配:  

int regexec(const  regex_t  *preg,  const  char *string, size_t nmatch,regmatch_t pmatch[], int eflags); 
typedef struct { 
  regoff_t rm_so; 
  regoff_t rm_eo; 
} regmatch_t; 
  
参数preg指向编译后的正则表达式,参数string是将要进行匹配的字符串,而参数nmatch和pmatch则用于把匹配结果返回给调用程序,最后一个参数eflags决定了匹配的细节。  

在调用函数regexec()进行模式匹配的过程中,可能在字符串string中会有多处与给定的正则表达式相匹配,参数pmatch就是用来保存这些匹配位置的,而参数nmatch则告诉函数regexec()最多可以把多少个匹配结果填充到pmatch数组中。当regexec()函数成功返回时,从string+pmatch[0].rm_so到string+pmatch[0].rm_eo是第一个匹配的字符串,而从string+pmatch[1].rm_so到string+pmatch[1].rm_eo,则是第二个匹配的字符串,依此类推。  

释放正则表达式  

无论什么时候,当不再需要已经编译过的正则表达式时,都应该调用函数regfree()将其释放,以免产生内存泄漏。  

void regfree(regex_t *preg); 

函数regfree()不会返回任何结果,它仅接收一个指向regex_t数据类型的指针,这是之前调用regcomp()函数所得到的编译结果。  

如果在程序中针对同一个regex_t结构调用了多次regcomp()函数,POSIX标准并没有规定是否每次都必须调用regfree()函数进行释放,但建议每次调用regcomp()函数对正则表达式进行编译后都调用一次regfree()函数,以尽早释放占用的存储空间。  

报告错误信息  

如果调用函数regcomp()或regexec()得到的是一个非0的返回值,则表明在对正则表达式的处理过程中出现了某种错误,此时可以通过调用函数regerror()得到详细的错误信息。  

size_t regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size); 

参数errcode是来自函数regcomp()或regexec()的错误代码,而参数preg则是由函数regcomp()得到的编译结果,其目的是把格式化消息所必须的上下文提供给regerror()函数。在执行函数regerror()时,将按照参数errbuf_size指明的最大字节数,在errbuf缓冲区中填入格式化后的错误信息,同时返回错误信息的长度。  

应用正则表达式  

最后给出一个具体的实例,介绍如何在C语言程序中处理正则表达式。  

#include <stdio.h>; 
#include <sys/types.h>; 
#include <regex.h>; 
/* 取子串的函数 */ 
static char* substr(const char*str, unsigned start, unsigned end) 
{ 
  unsigned n = end - start; 
  static char stbuf[256]; 
  strncpy(stbuf, str + start, n); 
  stbuf[n] = 0; 
  return stbuf; 
} 
/* 主程序 */ 
int main(int argc, char** argv) 
{ 
  char * pattern; 
  int x, z, lno = 0, cflags = 0; 
  char ebuf[128], lbuf[256]; 
  regex_t reg; 
  regmatch_t pm[10]; 
  const size_t nmatch = 10; 
  /* 编译正则表达式*/ 
  pattern = argv[1]; 
  z = regcomp(®, pattern, cflags); 
  if (z != 0){ 
    regerror(z, ®, ebuf, sizeof(ebuf)); 
    fprintf(stderr, "%s: pattern '%s' /n", ebuf, pattern); 
    return 1; 
  } 
  /*  逐行处理输入的数据 */ 
  while(fgets(lbuf, sizeof(lbuf), stdin)) { 
    ++lno; 
    if ((z = strlen(lbuf)) > 0 && lbuf[z-1] == '/n') 
      lbuf[z - 1] = 0; 
    /* 对每一行应用正则表达式进行匹配 */ 
    z = regexec(®, lbuf, nmatch, pm, 0); 
    if (z == REG_NOMATCH) 
       continue; 
    else if (z != 0) { 
      regerror(z, ®, ebuf, sizeof(ebuf)); 
      fprintf(stderr, "%s: regcom('%s')/n", ebuf, lbuf); 
      return 2; 
    } 
    /* 输出处理结果 */ 
    for (x = 0; x < nmatch && pm[x].rm_so != -1; ++ x) { 
      if (!x) printf("%04d: %s/n", lno, lbuf); 
      printf("  %d='%s'/n", x, substr(lbuf, pm[x].rm_so, pm[x].rm_eo)); 
    } 
  } 
  /* 释放正则表达式  */ 
  regfree(®); 
  return 0; 
} 

 

 

TCL/Tk一句话笔记(一)

1. A backslash as the last character in a line is converted into a space, and all the white space at the beginning of the next line is replaced by this substitution.

2. The difference between double quotes and curly braces is that quotes allow substitutions to occur in the group, while curly braces prevent substitutions.
3. Tcl uses the proc command to define procedures.
4. The expr command is used to parse and evaluate math expressions. You can make expr operate more efficiently by grouping the entire expression in curly braces.
5. TCL assumes that variable names contain only letters, digits, and the underscore. The construct $foo.o represents a concatenation of the value of foo and the literal ".o".
6. If the variable reference is not delimited by punctuation or white space, then you can use curly braces to explicitly delimit the variable name (e.g., ${x}).
7. You can delete a variable with the unset command:
unset ?-nocomplain? ?--? varName varName2 ...
8. The existence of a variable can be tested with the info exists command.
9. You should always group expressions in curly braces and let expr do command and variable substitutions.
10. In TCL, the # must occur at the beginning of a command.
11. A surprising property of Tcl comments is that curly braces inside comments are still counted for the purposes of finding matching brackets.
12. Command arguments are separated by white space, unless arguments are grouped with curly braces or double quotes as described below. If you forget the space, you will get syntax errors about unexpected characters after the closing brace or quote.
13. The Tcl shells pass the command-line arguments to the script as the value of the argv variable. The number of command-line arguments is given by the argc variable. The name of the program, or script, is not part of argv nor is it counted by argc. Instead, it is put into the argv0 variable. argv is a list, so you can use the lindex command to extract items from it:

set arg1 [lindex $argv 0]
14. Some command-line options are interpreted by wish, and they do not appear in the argv variable. The general form of the wish command line is:
wish ?options? ?script? ?arg1 arg2?

If no script is specified, then wish just enters an interactive command loop.

15. You can use the info script command to find out where the CGI script is, and from that load the supporting file. The file dirname and file join commands manipulate file names in a platform-independent way.

set dir [file dirname [info script]] 

set datafile [file join $dir guestbook.data]

16. You can ask string for valid operations by giving it a bad one:

string junk
=> bad option "junk": should be bytelength, compare, equal, first, index, is, last, length
graphics/ccc.gif, map, match, range, repeat, replace, tolower, totitle, toupper, trim, trimleft, trimright,
graphics/ccc.gif wordend, or wordstart
17. The string map command translates a string based on a character map. The map is in the form of a input, output list. Wherever a string contains an input sequence, that is replaced with the corresponding output. For example:
string map {f p d l} food
=> pool

The inputs and outputs can be more than one character and they do not have to be the same length:

string map {f p d ll oo u} food
=> pull
18. A position specifier is i$, which means take the value from argument i as opposed to the normally corresponding argument. The position counts from 1. If a position is specified for one format keyword, the position must be used for all of them. If you group the format specification with double quotes, you need to quote the $ with a backslash:
    set lang 2
    format "%${lang}/$s" one un uno
    => un
19. The binary command provides conversions between strings and packed binary data representations. The binary format command takes values and packs them according to a template. The resulting binary value is returned:

binary format template value ?value ...?

The binary scan command extracts values from a binary string according to a similar template. It assigns values to a set of Tcl variables:

    binary scan value template variable ?variable ...?
20. Tcl commands described are: list, lindex, llength, 
lrange, lappend, linsert, lreplace,
lsearch, lset, lsort, concat, join,
and split.
21. Tcl commands related to list are: list, lindex, llength, lrange, lappend, linsert, lreplace, lsearch, lset, lsort, concat, join, and split.
22. Procedure
22.1 Default parameter values

    proc P2 {a {b 7} {c -2} } {
     expr $a / $b + $c
    }
    P2 6 3
    => 0
22.2 A procedure can take a variable number of arguments by 
specifying the args keyword as the last parameter. When the procedure 
is called, the args parameter is a list that contains all the remaining 
values.
23. The rename command changes the name of a command: 
        rename foo foo.orig
The other thing you can do with rename is completely remove a command by renaming it to the empty string:
        rename exec {}
24. Use the upvar command when you need to pass the name of a variable, as 
opposed to its value, into a procedure.
25. Call by Name Using upvar
Use the upvar command when you need to pass the name of a variable, as opposed to its value, into a procedure. The upvar command associates a local variable with a variable in a scope up the Tcl call stack. The syntax of the upvar command is:

    upvar ?level? varName localvar

The level argument is optional, and it defaults to 1, which means one level up the Tcl call stack. You can specify some other number of frames to go up, or you can specify an absolute frame number with a #number syntax. Level #0 is the global scope.

26. You can use any string as an index for array, but avoid using a string that contains spaces.

27. The array get and array set operations are used to convert between an array and a list. The list returned by array get has an even number of elements. The first element is an index, and the next is the corresponding array value. The list elements continue to alternate between index and value. The list argument to array set must have the same structure.

28. 

用PERL处理二进制标量

 PERL Handling Binary Scalar

1 [Question]:

I adopt select()...sysread()...syswrite() mechanism to handle socket messages, where messages are sysread() into $buffer (binary) before they are syswritten.

Now I want to change two bytes of the message, which denote the length of the whole message. At first, I use following code:

my $msglen=substr($buffer,0,2); # Get the first two bytes
my $declen=hex($msglen);
$declen
+= 3;
substr
($buffer,0,2,$declen); # change the length

However, it doesn't work in this way. If the final value of $declen is 85, then the modified $buffer will be "0x35 0x35 0x00 0x02...". I insert digital number to $buffer but finally got ASCII!

I also tried this way:

my $msglen=substr($buffer,0,2); # Get the first two bytes,binary
$msglen
+= 0b11; # Or $msglen += 3;
my $msgbody=substr($buffer,2); # Get the rest part of message, binary
$buffer
=join("", $msglen, $msgbody);

Sadly, this method also failed. The result is such as"0x33 0x 0x00 0x02..." I just wonder why two binary scalar can't be joined into a binary scalar?

Can you help me? Thank you!

[Answer 1]: 

 

my $msglen=substr($buffer,0,2); # Get the first two bytes
my $number = unpack("S",$msglen);
$number
+= 3;
my $number_bin = pack("S",$number);
substr
($buffer,0,2,$number_bin); # change the length

 

[Answer 2]:

用vec。 

比如: 

Perl code
my $buffer = "/x00/x01"; print unpack("H*", $buffer), "/n"; vec($buffer, 0, 16) += 3; print unpack("H*", $buffer), "/n";

[Question]:

I am writing a Perl program that sends and receives messages from two sockets and acta as a switch. I have to modify the received messages received from one socket, prepend 3 bytes to the data, and finally send the modified messages to another socket. I adopt select()...sysread()...syswrite() mechanism to poll for messages between sockets. The received messages are stored in $buffer during modification.

Now I can use following way to get the received messages:

my $hexmsg = unpack("H*", $buffer);
my @msg = ( $hexmsg =~ m/../g );

then I can insert 3 bytes to @msg. However, I don't know how to pack the message in @msg into a scalar(such as $buffer) and send it to another socket by syswrite(). Can anybody help me? Thank you in advance!

BTW, are messages in $buffer binary?

[Answer]:

 

Yes, messages in $buffer are binary (if I'm guessing what you mean by that correctly). If your only reason for unpacking it into @msg is to insert the bytes, don't. Use substr instead, and just write out the changed $buffer. For instance:

substr( $buffer, 0, 0, "/x01/x02/x03" ); # insert 3 bytes at beginning.

If you are doing other things with @msg, you could continue to use that as well as doing the substr insert before writing it out, or you could use substr or pack or split or vec or a regex to parse out the pieces you need. You'd need to describe what you are doing to get more specific help.

 

PERL打印收到的Socket消息

 

PERL打印收到的Socket消息

利用Perl的Select(),sysread()和syswrite()收到的消息将以二进制的形式存储到$buffer中,因此如果直接打印$buffer的内容将得到乱码。要将二进制内容转换为十六进制数串,则必须使用unpack()函数,即:
my $hexstr=unpack("H*",$buffer);
而此时如果打印$hexstr将得到一系列的十六进制数串(数串的长度是接收到的字节数的两倍),仍然难以阅读。因此,有必要将十六进制数串每两个数字进行拆分并加前缀“0x”以便阅读。此时需要借助正则表达式进行模式匹配,方法为:
my @msg=($hexstr =~ m/../g);
其中.用以匹配一个字符。
示例代码如下:
##################################################################
#               DumpMsg
#
# Dump received message in hex mode.
#
# Format: DumpMsg($type, $msglen, $msg);
#
# input:        $type= 'MSC' | 'BSC'
#               $msglen= msg length
#               $msg= received msg
#
# output:       Print received msg to stderr and log in hex type
##################################################################
sub DumpMsg {
    my $type=$_[0];
    my $msglen=$_[1];
    CoolMisc::coolprint("Received message from $type: $msglen bytes/n" );
    LogPrint("Received message from $type: $msglen bytes/n");
    # change the received message from bin to hex string.
    # my @msg=split(/../,unpack("H*", $_[2]),$msglen);
    my $tmp = unpack("H*", $_[2]);
    my @msg = ( $tmp =~ m/../g );
    # print the message to stdout and log file.
    for(my $i=0;$i<$msglen;$i++) {
        print "0x$msg[$i] ";
        syswrite($ROUTELOG,"0x$msg[$i] ");
        if ($i%8 ==7) {
            print "/n";
            syswrite($ROUTELOG,"/n");
        }
    }
    print "/n";
    syswrite($ROUTELOG,"/n");
}

 

参考文献:

 

Perl数值转换

As always with Perl there is more than one way to do it. Below are a few examples of approaches to making common conversions between number representations. This is intended to be representational rather than exhaustive.

Some of the examples below use the Bit::Vector module from CPAN. The reason you might choose Bit::Vector over the perl built in functions is that it works with numbers of ANY size, that it is optimized for speed on some operations, and for at least some programmers the notation might be familiar.

How do I convert hexadecimal into decimal

Using perl's built in conversion of 0x notation:

 

    $int = 0xDEADBEEF;
    $dec = sprintf("%d", $int);  

 

Using the hex function:

 

    $int = hex("DEADBEEF");
    $dec = sprintf("%d", $int);  

 

Using pack:

 

    $int = unpack("N", pack("H8", substr("0" x 8 . "DEADBEEF", -8)));
    $dec = sprintf("%d", $int);  

 

Using the CPAN module Bit::Vector:

 

    use Bit::Vector;
    $vec = Bit::Vector->new_Hex(32, "DEADBEEF");
    $dec = $vec->to_Dec();  

 

How do I convert from decimal to hexadecimal

Using sprint:

 

    $hex = sprintf("%X", 3735928559);  

 

Using unpack

 

    $hex = unpack("H*", pack("N", 3735928559));  

 

Using Bit::Vector

 

    use Bit::Vector;
    $vec = Bit::Vector->new_Dec(32, -559038737);
    $hex = $vec->to_Hex();  

 

And Bit::Vector supports odd bit counts:

 

    use Bit::Vector;
    $vec = Bit::Vector->new_Dec(33, 3735928559);
    $vec->Resize(32); # suppress leading 0 if unwanted
    $hex = $vec->to_Hex();  

 

How do I convert from octal to decimal

Using Perl's built in conversion of numbers with leading zeros:

 

    $int = 033653337357; # note the leading 0!
    $dec = sprintf("%d", $int);  

 

Using the oct function:

 

    $int = oct("33653337357");
    $dec = sprintf("%d", $int);  

 

Using Bit::Vector:

 

    use Bit::Vector;
    $vec = Bit::Vector->new(32);
    $vec->Chunk_List_Store(3, split(//, reverse "33653337357"));
    $dec = $vec->to_Dec();  

 

How do I convert from decimal to octal

Using sprintf:

 

    $oct = sprintf("%o", 3735928559);  

 

Using Bit::Vector

 

    use Bit::Vector;
    $vec = Bit::Vector->new_Dec(32, -559038737);
    $oct = reverse join('', $vec->Chunk_List_Read(3));  

 

How do I convert from binary to decimal

Perl 5.6 lets you write binary numbers directly with the 0b notation:

 

	$number = 0b10110110;  

 

Using pack and ord

 

    $decimal = ord(pack('B8', '10110110'));  

 

Using pack and unpack for larger strings

 

    $int = unpack("N", pack("B32",
	substr("0" x 32 . "11110101011011011111011101111", -32)));
    $dec = sprintf("%d", $int);


            
          

UNIX Commands Used to Debug

UNIX Commands Used to Debug

1. truss

bjbldc:/home/bonny >2> truss -p 6535
read(11, 0xFFBED6C8, 1024)      (sleeping...)

2. ps -fu <user_name>

bjbldc:/home/bonny >> ps -fu bonny
     UID   PID  PPID  C    STIME TTY      TIME CMD
   bonny  9006  9005  0   Feb 26 ??       0:01 /usr/dt/bin/dtterm
   bonny 19743  8910  0   Feb 26 ?        0:00 dtfile -session dtstaGjf
   bonny  8784  8776  0   Feb 16 ?        0:13 dtwm
   bonny  8911  8776  0   Feb 16 ??       0:01 /usr/dt/bin/dtterm -session dt_.a
q4t -C -ls
   bonny 18994  8784  0   Feb 26 ?        0:00 /usr/dt/bin/dtexec -open 0 -ttpro
cid 2.19cDSU 01 8751 1289637095 1 1 39237 135.
   bonny 25275     1  0   Feb 25 ?        0:11 gvim BMAcpMsgpr.c
   bonny 25106  8911  0   Feb 25 pts/186  0:00 -ksh

3. ptree <user_name>

bjbldc:/home/bonny >> ptree bonny
195   /usr/sbin/inetd -s
  6224  in.rshd
    6225  dtterm -xrm *workspaceList: COOL msc-s COOL/ msc-s -title COOL msc-s Installing
      6252  tail -f /bld/bonny/coolxdir_2/logs/Mar02.18:42:41/APs/31/COOLAPLOG
  6254  in.rshd
    6256  dtterm -xrm *workspaceList: COOL msc-s COOL/ msc-s -title COOL msc-s Installing
      6276  tail -f /bld/bonny/coolxdir_2/logs/Mar02.18:42:41/APs/33/COOLAPLOG
  6278  in.rshd
    6279  dtterm -xrm *workspaceList: COOL msc-s COOL/ msc-s -title COOL msc-s Installing
      6300  tail -f /bld/bonny/coolxdir_2/logs/Mar02.18:42:41/APs/35/COOLAPLOG
  6297  in.rshd
    6298  /usr/bin/ksh /opt/cool/tools/lib/COOLvirtenv -r /bld/bonny/coolxdir_2/APs/31 -a
      6535  /usr/bin/ksh /opt/cool/tools/lib/COOLstartAP -sL -c80 -Wcool01 -Fcoolap23 -dOWL
  6335  in.rshd
    6336  /usr/bin/ksh /opt/cool/tools/lib/COOLvirtenv -r /bld/bonny/coolxdir_2/APs/35 -a
      6627  /usr/bin/ksh /opt/cool/tools/lib/COOLstartAP -sA -c80 -Wcool01 -Fcoolap09 -dOWL

4. uptime

 cool01:/home/bonny >> uptime
 10:17pm  up 18:10,  2 users,  load average: 0.03, 0.01, 0.06

5. uname

cool01:/home/bonny >127> uname -a
SunOS cool01 5.8 Generic_117350-58 sun4u sparc SUNW,UltraAX-i2
bjbldc:sc4.2/SUNWspro/bin >> uname -n
bjbldc

6. nmake

bjbldb:bld/bonny/1apx10 >> nmake GLIB10=N -n -k -f mytstmk dumpit                    
+ set +x
+ cd /bld/bonny/1apx10
+ /bin/pwd
+ set -x
+ : "STARTING ecpc NMAKE IN ROOT `silent date '+%m/%d/%y %H:%M:%S'`"
+ print FMS_GOLDEN_HDRLIB=
FMS_GOLDEN_HDRLIB=
+ rm -f 
+ : "COMPLETED ecpc NMAKE IN ROOT `silent date '+%m/%d/%y %H:%M:%S'`"

7. lb

bjbldb:bld/bonny/1apx10 >> lb -iA -mapbld
 LB Pool Status for apbld  (03/02/09 23:58:21):
 MACH                  RTP  %AV  RSP  CPUF  MLA IMLA  PLA  LA1   LA5   LA15
bjbldb                1400   99   1  1406  20.2  20  0.08  0.06  0.08  0.30
bjbldc                1394   99   3  1406  20.2  20  0.17  0.16  0.20  0.29
bjbldd                1363   96   2  1406  20.2  20  0.61  0.60  0.63  0.69
------------------------------------------------------------------------------
AVERAGE               1385   98   -  1406  20.2  20  0.29  0.27  0.30  0.43
TOTAL                 4157   98   3  4218  60.6  60  0.86  0.82  0.91  1.28
        apbld :  98% available   (98% available IMLA) 
bjbldb:bld/bonny/1apx10 >> lb -m bjbldc nmake GLIB10=N -n -k -f mytstmk dumpit
+ set +x
+ cd /bld/bonny/1apx10
+ /bin/pwd
+ set -x
+ : "STARTING ecpc NMAKE IN ROOT `silent date '+%m/%d/%y %H:%M:%S'`"
+ print FMS_GOLDEN_HDRLIB=
FMS_GOLDEN_HDRLIB=
+ rm -f 
+ : "COMPLETED ecpc NMAKE IN ROOT `silent date '+%m/%d/%y %H:%M:%S'`"
bjbldb:bld/bonny/1apx10 >> lb -iA -m CoolServers.ngnap
 LB Pool Status for coolservers.ngnap  (03/03/09 00:15:06):
 MACH                  RTP  %AV  RSP  CPUF  MLA IMLA  PLA  LA1   LA5   LA15
coolap26              1361   94  21  1440  10.0  10  0.54  0.52  0.52  0.52
coolap14               698   99   1   700  10.0  10  0.02  0.00  0.00  0.01
coolap01               698   99   2   700  10.0  10  0.03  0.00  0.01  0.01
coolap12               698   99   4   700  10.0  10  0.02  0.00  0.00  0.01
coolap09               698   99   5   700  10.0  10  0.02  0.00  0.00  0.01
coolap21               698   99   6   700  10.0  10  0.02  0.00  0.00  0.01
coolap19               698   99  11   700  10.0  10  0.02  0.00  0.00  0.01
coolap13               698   99  13   700  10.0  10  0.02  0.00  0.00  0.01
coolap16               698   99  14   700  10.0  10  0.02  0.00  0.00  0.01
coolap24               698   99  16   700  10.0  10  0.02  0.00  0.00  0.01
coolap23               698   99  17   700  10.0  10  0.02  0.00  0.00  0.01
coolap25               698   99  19   700  10.0  10  0.02  0.00  0.00  0.01
coolap02               695   99   3   700  10.0  10  0.07  0.01  0.04  0.10
coolap18               695   99   7   700  10.0  10  0.06  0.04  0.04  0.06
coolap07               695   99   8   700  10.0  10  0.06  0.05  0.11  0.23
coolap05               695   99   9   700  10.0  10  0.07  0.05  0.05  0.10
coolap10               695   99  10   700  10.0  10  0.07  0.05  0.05  0.07
coolap20               695   99  15   700  10.0  10  0.06  0.02  0.04  0.06
coolap08               693   99  12   700  10.0  10  0.10  0.08  0.10  0.21
coolap17               691   98  18   700  10.0  10  0.13  0.11  0.13  0.12
coolap11               623   89  20   700  10.0  10  1.09  0.96  0.39  0.26
------------------------------------------------------------------------------
AVERAGE                724   98   -   735  10.0  10  0.12  0.09  0.07  0.09
TOTAL                15216   98  21 15440 210.0 210  2.48  1.89  1.48  1.84
        coolservers.ngnap :  98% available   (98% available IMLA) 
bjbldb:bld/bonny/1apx10 >> lb -iA -m coolservers
 LB Pool Status for coolservers  (03/03/09 00:31:49):
 MACH                  RTP  %AV  RSP  CPUF  MLA IMLA  PLA  LA1   LA5   LA15
cool01                 660   99   1   662  10.0  10  0.02  0.00  0.00  0.01
cool11                 660   99   6   662  10.0  10  0.02  0.00  0.00  0.01
cool05                 660   99   8   662  10.0  10  0.02  0.00  0.00  0.01
cool13                 660   99   9   662  10.0  10  0.03  0.01  0.00  0.01
cool02                 660   99  12   662  10.0  10  0.03  0.02  0.01  0.01
cool09                 659   99  10   662  10.0  10  0.04  0.01  0.01  0.03
cool08                 642   99   2   644  10.0  10  0.02  0.00  0.00  0.01
cool07                 642   99   5   644  10.0  10  0.02  0.00  0.00  0.01
cool10                 641   99  11   644  10.0  10  0.03  0.01  0.00  0.01
cool14                 591   89   3   662  10.0  10  1.07  1.05  1.03  1.04
cool12                 589   88   7   662  10.0  10  1.10  1.08  1.06  1.17
cool03                 376   56   4   662  10.0  10  4.32  4.14  3.36  2.59
------------------------------------------------------------------------------
AVERAGE                620   94   -   658  10.0  10  0.56  0.53  0.46  0.41
TOTAL                 7440   94  12  7890 120.0 120  6.72  6.32  5.47  4.91
        coolservers :  94% available   (94% available IMLA) 

8. timex 

timex- time a  command;  report  process  data  and  system activity.

bjbldb:bld/bonny/1apx10 >> timex ping cool01

cool01 is alive
real        0.01
user        0.01
sys         0.00

9. remsh

bjbldb:bld/bonny/1apx10 >> remsh bjbldd ps -fu bonny
     UID   PID  PPID  C    STIME TTY      TIME CMD
   bonny 29793 29752  0 22:18:04 pts/179  0:00 rlogin bjbldc
   bonny 15715 15669  0   Feb 26 ?        0:00 dtfile -session dtstaGjf
   bonny 23825 23779  0 00:38:20 ?        0:00 /usr/bin/remsh cool01 eval set -aSTART[0]=/home/bonny/.env[
   bonny  2409 15716  0 16:05:08 pts/41   0:00 -ksh
   bonny 14037     1  0 16:33:12 ?        0:01 gvim COOLein2ap
   bonny 15542 15541  0   Feb 26 ?        0:00 /opt/exp/lib/vnc/vncconfig.bin -nowin
   bonny 29545 29543  0 22:17:05 pts/195  0:00 /bin/ksh
   bonny 23779  2666  0 00:38:19 ?        0:00 /usr/bin/remsh cool01 eval set -aSTART[0]=/home/bonny/.env[
   bonny 24503 24502  0 20:49:36 ?        0:00 /bin/ksh /opt/cool/bin/clear3bemlab -i -p -lab bonny
   bonny 15498     1  1   Feb 26 ?        2:04 Xvnc :10 -desktop bjbldd:10 () -httpd /opt/exp/lib/vnc/clas
   bonny 23776     1  0 00:38:19 ?        0:00 /bin/ksh /opt/cool/tools/lib/GetDynCOOLID UNAME=coolap01 CO
   bonny 24175 24174  0 20:40:11 ?        0:00 /bin/ksh /opt/cool/bin/clear3bemlab -i -p -lab bonny
   bonny 13782 13780  0 16:28:08 pts/180  0:00 /bin/ksh
   bonny 24502 24343  0 20:49:36 ?        0:00 /bin/ksh /opt/cool/bin/ldcool -u bonny -e apollo -o is41 -l
   bonny 15668     1  0   Feb 26 pts/118  0:00 /usr/dt/bin/ttsession
   bonny 23482     1  0 00:38:15 ?        0:00 /bin/ksh /opt/cool/tools/lib/GetDynCOOLID UNAME=cool01
   bonny 19606     1  0 17:06:00 ?        0:12 gvim /apx/ecpc33/OFC5L33.0/1apx10/rules/tps.mk
   bonny  2666     1  0 16:07:01 ?        0:11 /opt/cool/tools/lib/TclPro1.5/solaris-sparc/bin/wish8.3 -f 
   bonny 28765 15692  0 22:14:32 ?        0:00 /usr/dt/bin/dtexec -open 0 -ttprocid 2.19fbdI 01 15668 1289
   bonny 13970 13969  0 13:45:33 ?        0:00 /bin/ksh /opt/cool/bin/ldcool -u bonny -e athena -o is41 -l
   bonny 28767 28765  0 22:14:32 ??       0:00 /usr/dt/bin/dtterm
   bonny 24588 24587  0 20:51:46 pts/41   0:00 rlogin cool01
   bonny 14189 14162  2 13:45:39 ?       40:47 rm -rf /opt/cool2b/bonny/APs/21
   bonny 15717 15669  0   Feb 26 ?        0:01 /usr/dt/bin/sdtperfmeter -f -H -t cpu -t disk -s 1 -name fp
   bonny 14126 14125  0 13:45:39 ?        0:00 /bin/ksh /opt/cool/bin/clear3bemlab -i -p -lab bonny
   bonny 15637 15635  0   Feb 26 pts/118  0:00 -ksh -c      unset DT;     DISPLAY=bjbldd:10;       /usr/dt
   bonny 15716 15669  0   Feb 26 ??       0:03 /usr/dt/bin/dtterm -session dt_.aq4t -C -ls
   bonny 23483 23482  0 00:38:15 ?        0:00 sleep 1800
   bonny 29752 29750  0 22:17:55 pts/179  0:00 /bin/ksh
   bonny 24132 24019  0 20:40:08 ?        0:00 tail +0f /tmp/ldcool.24019/log.ldcool_bonny_bonny
   bonny 15541     1  0   Feb 26 ?        0:00 /opt/exp/bin/ksh /opt/exp/lib/vnc/vncconfig -nowin
   bonny 29750 29749  0 22:17:55 ??       0:01 /usr/dt/bin/dtterm
   bonny 19600     1  0 17:05:59 pts/180  0:00 cscope -dl -f /apx/ecpc33/OFC5L33.0/1apx10/cscope/cscope.ou
   bonny 15692 15669  0   Feb 26 ?        0:15 dtwm
   bonny 15634     1  0   Feb 26 ?        0:00 /usr/dt/bin/dsdm
   bonny 29570 29569  0 22:17:09 pts/195  0:00 rlogin cool01
   bonny 29794 29793  0 22:18:04 pts/179  0:00 rlogin bjbldc
   bonny 13879     1  0 16:29:06 pts/180  0:00 cscope -dl -f /apx/ecpc33/OFC5L33.0/1apx10/cscope/cscope.ou
   bonny 14082 13970  0 13:45:38 ?        0:00 tail +0f /tmp/ldcool.13970/log.ldcool_bonny_bonny
   bonny 24019 24018  0 20:40:07 ?        0:00 /bin/ksh /opt/cool/bin/ldcool -u bonny -e apollo -o is41 -l
   bonny 23823 23779  0                   0:00 <defunct>
   bonny 14289     1  0 16:38:04 ?        0:19 gvim /opt/nwstools/bin/getnmakevar
   bonny 15533     1  0   Feb 26 ?        0:00 /bin/ksh /usr/dt/bin/Xsession
   bonny 28773 28767  0 22:14:33 pts/78   0:00 /bin/ksh
   bonny 29542 15692  0 22:17:05 ?        0:00 /usr/dt/bin/dtexec -open 0 -ttprocid 2.19fbdI 01 15668 1289
   bonny 15669 15637  0   Feb 26 pts/118  0:00 /usr/dt/bin/dtsession
   bonny 14162 14126  0 13:45:39 ?        0:00 /bin/ksh /opt/cool/tools/bin/rmv_coolap -C /opt/cool2b/bonn
   bonny 23777 23776  0 00:38:19 ?        0:00 sleep 1800
   bonny 24562 24503  1 20:49:36 ?       17:28 rm -rf APs
   bonny 29569 29545  0 22:17:09 pts/195  0:00 rlogin cool01
   bonny 24232 24175  3 20:40:11 ?       15:44 rm -rf APs
   bonny 14125 13970  0 13:45:39 ?        0:00 /bin/ksh /opt/cool/bin/ldcool -u bonny -e athena -o is41 -l
   bonny 15635 15533  0   Feb 26 pts/118  0:00 /usr/dt/bin/sdt_shell -c      unset DT;     DISPLAY=bjbldd:
   bonny 13779 15692  0 16:28:08 ?        0:00 /usr/dt/bin/dtexec -open 0 -ttprocid 2.19fbdI 01 15668 1289
   bonny 13882     1  0 16:29:07 ?        0:10 gvim coolit
   bonny 14034     1  0 16:33:12 pts/180  0:00 cscope -dl -f /apx/ecpc33/OFC5L33.0/1apx10/cscope/cscope.ou
   bonny 14286     1  0 16:38:03 pts/180  0:00 cscope -dl -f /apx/ecpc33/OFC5L33.0/1apx10/cscope/cscope.ou
   bonny 29749 15692  0 22:17:55 ?        0:00 /usr/dt/bin/dtexec -open 0 -ttprocid 2.19fbdI 01 15668 1289
   bonny 24343 24342  0 20:49:33 ?        0:00 /bin/ksh /opt/cool/bin/ldcool -u bonny -e apollo -o is41 -l
   bonny 24460 24343  0 20:49:35 ?        0:00 tail +0f /tmp/ldcool.24343/log.ldcool_bonny_bonny
   bonny 29543 29542  0 22:17:05 ??       0:01 /usr/dt/bin/dtterm
   bonny 13780 13779  0 16:28:08 ??       0:00 /usr/dt/bin/dtterm
   bonny 24174 24019  0 20:40:11 ?        0:00 /bin/ksh /opt/cool/bin/ldcool -u bonny -e apollo -o is41 -l
   bonny 24587  2409  0 20:51:46 pts/41   0:00 rlogin cool01
bjbldb:bld/bonny/1apx10 >> remsh bjbldd ps -fu bonny | grep nmake
   bonny 14289     1  0 16:38:04 ?        0:19 gvim /opt/nwstools/bin/getnmakevar