2010-04-10

[iBook G4 / Mac OS X 10.4] Compile expect 5.44.1.15 againt Tcl 8.5.8 without Tk

  • Compile tcl-8.5.8:
  • $ ./configure ...
    $ make
    $ sudo make install
    $ sudo make install-private-headers
  • Compile expect-5.44.1.15:
    • Follow instructions of this post.
    • OSX has no ldconfig and /etc/ld.so.conf. To run the compiled expect, first export DYLD_LIBRARY_PATH=/usr/local/expect-5.44.1.15/lib/expect5.44.1.15. Man dyld for more details.

2009-05-05

Output of the free command

$ free
. total used free shared buffers cached
Mem: 514816 344028 170788 0 37820 200120
-/+ buffers/cache: 106088 408728
Swap: 1502036 96468 1405568
Mem:表示物理内存统计
-/+ buffers/cached:表示物理内存的缓存统计
Swap:表示硬盘上交换分区的使用情况,这里我们不去关心。
系统的总物理内存:255268Kb(256M),但系统当前真正可用的内存b并不是第一行free 标记的 16936Kb,它仅代表未被分配的内存。

第1行 Mem
total:表示物理内存总量。
used:表示总计分配给缓存(包含buffers 与cache )使用的数量,但其中可能部分缓存并未实际使用。
free:未被分配的内存。
shared:共享内存,一般系统不会用到,这里也不讨论。
buffers:系统分配但未被使用的buffers 数量。
cached:系统分配但未被使用的cache 数量。buffer 与cache 的区别见后面。
total = used + free

第2行 -/+ buffers/cached
used:也就是第一行中的used - buffers-cached 也是实际使用的内存总量。
free:未被使用的buffers 与cache 和未被分配的内存之和,这就是系统当前实际可用内存。
free 2= buffers1 + cached1 + free1 //free2为第二行、buffers1等为第一行

buffer 与cache 的区别:
A buffer is something that has yet to be "written" to disk.
A cache is something that has been "read" from the disk and stored for later use 第3行: 第三行所指的是从应用程序角度来看,对于应用程序来说,buffers/cached 是等于可用的,因为buffer/cached是为了提高文件读取的性能,当应用程序需在用到内存的时候,buffer/cached会很快地被回收。所以从应用程序的角度来说,可用内存=系统free memory+buffers+cached.

接下来解释什么时候内存会被交换,以及按什么方交换。
当可用内存少于额定值的时候,就会开会进行交换.
如何看额定值(RHEL4.0):
#cat /proc/meminfo
交换将通过三个途径来减少系统中使用的物理页面的个数: 
1. 减少缓冲与页面cache的大小,
2. 将系统V类型的内存页面交换出去, 
3. 换出或者丢弃页面。(Application 占用的内存页,也就是物理内存不足)。
事实上,少量地使用swap是不是影响到系统性能的。

下面是buffers与cached的区别。
buffers是指用来给块设备做的缓冲大小,他只记录文件系统的metadata以及 tracking in-flight pages.
cached是用来给文件做缓冲。
那就是说:buffers是用来存储,目录里面有什么内容,权限等等。
而cached直接用来记忆我们打开的文件,如果你想知道他是不是真的生效,你可以试一下,先后执行两次命令#man X ,你就可以明显的感觉到第二次的开打的速度快很多。
实验:在一台没有什么应用的机器上做会看得比较明显。记得实验只能做一次,如果想多做请换一个文件名。
#free
#man X
#free
#man X
#free
你可以先后比较一下free后显示buffers的大小。
另一个实验:
#free
#ls /dev
#free
你比较一下两个的大小,当然这个buffers随时都在增加,但你有ls过的话,增加的速度会变得快,这个就是buffers/chached的区别。
因为Linux将你暂时不使用的内存作为文件和数据缓存,以提高系统性能,当你需要这些内存时,系统会自动释放(不像windows那样,即使你有很多空闲内存,他也要访问一下磁盘中 的pagefiles)
使用free命令
将used的值减去 buffer和cache的值就是你当前真实内存使用
-------------- 操作系统来讲是Mem的参数.buffers/cached 都是属于被使用,所以它认为free只有16936.
应用程序来讲是(-/+ buffers/cach).buffers/cached 是等同可用的,因为buffer/cached是为
了提高 程序执行的性能,当程序使用内存时,buffer/cached会很快地被使用。 所以,以应用来看看,以(-/+ buffers/cache)的free和used为主.所以我们看这个就好了.另外告诉大家 一些常识.Linux为了提高磁盘和内存存取效率, Linux做了很多精心的设计, 除了对dentry进行缓存(用于 VFS,加速文件路径名到inode的转换), 还采取了两种主要Cache方式:Buffer Cache和Page Cache。 前者针对磁盘块的读写,后者 针对文件inode的读写。这些Cache能有效缩短了 I/O系统调用(比如read,write,getdents)的时间。 记住内存是拿来用 的,不是拿来看的.不象windows,无论你的真实物理内存有多少,他都要拿硬盘交换 文件来读.这也就是windows为什么常常提示虚拟空间不足的原因.你们想想,多无聊,在内存还有大部分 的时候,拿出一部分硬盘空间来充当内存.硬盘怎么会快过内存.所以我们看linux,只要不用swap的交换 空间,就不用担心自己的内存太少.如果常常swap用很多,可能你就要考虑加物理内存了.这也是linux看 内存是否够用的标准哦.

2009-04-27

Tclreadline

The tclreadline package makes the GNU Readline library available for interactive tcl shells. This includes history expansion and file/command completion. Command completion for all tcl/tk commands is provided and commmand completers for user defined commands can be easily added. tclreadline can also be used for tcl scripts which want to use a shell like input interface. In this case the ::tclreadline::readline read command has to be called explicitly.

SEE ALSO: Pure-Tcl Readline, Pure-Tcl Readline (2)

2009-04-17

ssh -t hostname vim /your/file

ssh -t

Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g., when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.

2009-04-16

Use rlwrap to add readline support to tclsh

rlwrap [1] is a GNU readline wrapper. it adds readline editing and command history to any command line app.To use it with tclsh, start tclsh with:

$ rlwrap tclsh
Useful options are -c (file name completion) and -f (add words from a file to the completion list).To use rlwrap with tclsh with file name completion type:
$ rlwrap -c tclsh
It would be nice to have a file of all words used in Tcl: commands and subcommands to set rlwrap up using the -f option.info commands and info procs could help with that. Maybe there are some *.syn files out there to provide such a database.

2009-04-15

Give up OS X on iBook G4

OS X 系统的不 open 导致的痛苦由来已久,早有心意弃之,一直未下决心。现苹果已转投 Intel,放弃 PowerPC,天晓得我的 iBook 还能支持到什么时候?干脆先苹果一步,主动抛弃 OS X,换成了 Debian 5(code named Lenny)。

2009-04-13

About Bash4

ABS Guide 的作者 Mendel Cooper 在 6.0.05 版中对 Bash4 有如下 Editorial comment:

Associative arrays? Coprocesses? Whatever happened to the lean and mean Bash we have come to know and love? Could it be suffering from (horrors!) "feature creep"? Or perhaps even Korn shell envy?

Note to Chet Ramey: Please add only essential features in future Bash releases -- perhaps for-each loops and support for multi-dimensional arrays. Most Bash users won't need, won't use, and likely won't greatly appreciate complex "features" like built-in debuggers, Perl interfaces, and bolt-on rocket boosters.

俺也感觉 bash4 的开发激进了些, 功能不稳定, feature 太花哨, 不几天的功夫 patch 已经出 17 个了. :(

Compile Expect 5.44.1.11 on Fedora 3

  • Checkout expect from Sourceforge.net
  • Open configure.in, comment out following lines:
    TEA_PATH_TKCONFIG
    TEA_LOAD_TKCONFIG
    TEA_PUBLIC_TK_HEADERS
  • Open Makefile.in:
  1. Remove expectk from var in_BINARIES
  2. Remove @TK_INCLUDES@ from var INCLUDES
  3. Remove @TK_LIB_SPEC@ and @TK_LIBS@
  • $ autoreconf -fiv
  • $ ./configure --prefix=/usr/local/expect-5.44 --exec-prefix=/usr/local/expect-5.44 --with-tcl=/usr/lib --with-tclinclude=/usr/include/tcl-private
  • $ make && make install
  • Open /etc/ld.so.conf, add one line: /usr/local/expect-5.44/lib/expect5.44.1.11
  • $ ldconfig
  • $ /usr/local/expect-5.44/bin/expect -v

Expectk

This is a stand alone interpreter which is the basic equivalent of

 #! /usr/bin/tclsh
package require Expect
package require Tk
Note that this interpreter is not intended to interact with Tk applications - instead, it is intended to allow one to write Tk applications that invoke expect in the background. This allows one to have a GUI interface to gather inputs, etc.

2009-04-11

About expect 5.44

http://expect.nist.gov/ was the original home Web site for Expect. It supplies sources and considerable history, background, and instruction. It does fail to mention, though, recognition [1] of Expect as one of the 100 most important publications of NIST's [2] first century. Note that the warning regarding expect 5.44 on that page is seriously out of date. The CVS 5.44 version linked to below is fine (and needed to build against Tcl 8.5).

The current maintenance of the package can be found at http://expect.sf.net/ , with access to the CVS available via sf.net's cvs repository. Note that the link (on the sf.net primary page) for the CVS repository is out of date; visit http://sf.net/projects/expect/ and use the link there to look at the cvs repository from your web browser.

This package is part of the ActiveTcl Batteries Included distribution on unix and as of 2005, the Windows version is available via ActiveTcl as well [3].

2009-04-07

Valgrind for PowerPC on Debian

$ valgrind ./invalid_free
valgrind: Fatal error at startup: a function redirection
valgrind: which is mandatory for this platform-tool combination
valgrind: cannot be set up. Details of the redirection are:
valgrind:
valgrind: A must-be-redirected function
valgrind: whose name matches the pattern: strlen
valgrind: in an object with soname matching: ld.so.1
valgrind: was not found whilst processing
valgrind: symbols from the object with soname: ld.so.1
valgrind:
valgrind: Possible fix: install glibc's debuginfo package on this machine.
valgrind:
valgrind: Cannot continue -- exiting now. Sorry.
$ aptitude install libc-dbg

2009-02-14

SSH Escape Char

man ssh and search Escape Char

2009-01-16

git-cvsimport

# apt-get install cvsps git-cvs

2009-01-15

Jabber.no out of service?

周一开始 gtalk 不能登录 msn 了, 这几天也不行, 难道 jabber.no 报废了?

2009-01-14

Mac version of Picasa is only for Intel-based machines?

很兴奋 google 终于推出了 mac 版的 picasa, 刚下载了一个, 结果不能运行, 上网一查原来只支持 intel 版的 mac, 可怜俺的 ibook g4, 伤心 :(

[Tiger] port install git-core +svn

To use git-svn, run sudo port install git-core +svn.

CPAN Reinitialization

cpan> o conf init

2008-12-16

How to Change the Ephemeral Port Range

Linux allows you to view and change the ephemeral port range by simply using the file /proc/sys/net/ipv4/ip_local_port_range. For example, this shows the default configuration on a kernel 2.2 system:

$ cat /proc/sys/net/ipv4/ip_local_port_range
1024 4999

To change this to the preferred range, you could do (as superuser):

# echo "49152 65535" > /proc/sys/net/ipv4/ip_local_port_range 

2008-12-15

Thunderbird Add-on

  • Buttons!
  • Google Contacts
  • MinimizeToTray
  • Send Later
  • Message Filter Import/Export

2008-10-28

Install Ubuntu 8.04 from Hard Disk

  • Make an ISO file ubuntu804.iso from Ubuntu's LiveCD (8.04 desktop), put the ISO file in D:/ubuntu804.iso
  • Mount the ISO file or the LiveCD, copy two files CDROM:/casper/{initrd.gz,vmlinuz} to Windows drive D:/
  • Download grub4dos, extract its files to C:/
  • Edit C:/boot.ini, add one new line: C:\grldr="GRUB4DOS"
  • Edit C:/menu.lst
    title Find and Install Ubuntu
    find --set-root /ubuntu804.iso
    kernel /vmlinuz boot=casper iso-scan/filename=/ubuntu804.iso
    initrd /initrd.gz
  • Reboot Windows XP
  • Select GRUB4DOS from the boot menu
  • ... ...
  • Will boot to the same screen as if you're directly booting from the LiveCD.