Cun Zhang’s Blog

May 29, 2008

filezilla as sftp client

Filed under: Linux, Windows — Tags: , — Cun Zhang @ 12:55

Today I review filezilla’s homepage, and find it has supported SSH File Transfer Protocol (SFTP). A few days before, I have search a good sftp client for so many times, but just find winscp and SSH Secure File Transfer Client.

Of course, the last two are good too, but I like filezilla more :)

The following is about FileZilla Features

Overview

FileZilla Client is a fast and reliable cross-platform FTP, FTPS and SFTP client with lots of useful features and an intuitive interface.

Features

Among others, the features of FileZilla include the following:

  • Easy to use
  • Supports FTP, FTP over SSL/TLS (FTPS) and SSH File Transfer Protocol (SFTP)
  • Cross-platform. Runs on Windows, Linux, *BSD, OSX and more
  • Available in many languages
  • Supports resume and transfer of large files >4GB
  • Powerful Site Manager and transfer queue
  • Drag & drop support
  • Configurable Speed limits
  • Filename filters
  • Network configuration wizard
  • Remote file editing
  • Keep-alive
  • FTP-Proxy support

May 28, 2008

linux screen command’s usage

Filed under: Linux — Tags: — Cun Zhang @ 17:14

Screen is a must have for anyone that works on remote boxes via the command line. There are many reasons for this, but a few of them are:
1. screen is an easy way to allow processes to continue running after the session is terminated
2. if you lose connection screen will save your spot

The following is  about how to use screen command:

screen [options] [command [args] ]

Provide ANSI/VT100 terminal emulation, making it possible to run multiple full-screen pseudo-terminals from one real terminal, and letting you manipulate and save your screen input and output, copy and paste between windows, etc.

Options

-a

Include all capabilities in each window’s termcap.

-A

Adapt all windows to the size of the current terminal. Default is to try to use the previous window size.

-c file

Use file as the configuration file instead of the default $HOME/.screenrc.

-d

Detach session running elsewhere. With -r, reattach to this terminal. With -R, reattach to this terminal or create it if it doesn’t already exist. With -RR, use the first session when reattaching if more than one session is available.

-D

Detach session running elsewhere, logging out before detaching. With -r, reattach to this terminal. With -R, reattach to this terminal or create it if it doesn’t already exist. With -RR, do whatever is necessary to create a new session.

-e xy

Change command characters. Specify x as the command character (default Ctrl-a) and y as the character that generates a literal command character (default a). Specify in caret notation (e.g., -e ^Pp to set Ctrl-p as the command character, which is useful for emacs-mode shell ).

-f, -fn, -fa

Turn flow control on, off, or to automatic-switching mode.

-h num

Specify the size of the history scrollback buffer.

-i

Cause the interrupt key (usually Ctrl-c) to interrupt the display immediately when flow control is on. Use of this option is discouraged.

-l, -ln

Turn login mode on or off for /etc/utmp updating.

-ls, -list

Print list of pid.tty.host strings identifying screen sessions.

-L

Tell screen that automargin terminal has a writable last position.

-m

Ignore the $STY environment variable and create a new session. With -d, start session in detached mode; useful for scripts. With -D, start session in detached mode but don’t fork a new process; the command exits if the session terminates.

-O

Use optimal output mode for terminal rather than true VT100 emulation.

-p window

Preselect the specified window if it exists.

-q

Suppress error message printing on startup. Exit with nonzero return code if unsuccessful.

-r [pid.tty.host]

-r sessionowner/[pid.tty.host]

Resume detached session. No other options except -d or -D can be specified. With sessionowner, resume another user’s detached session; requires setuid root.

-R

Attempt to resume the first session found, or start a new session with the specified options. Set by default if screen is run as a login shell.

-s shell

Set the default shell, overriding the $SHELL environment variable.

-S name

Specify a name for the session being started.

-t name

Set the window’s title.

-T term

Set $TERM to term instead of “screen”.

-U

Run in UTF-8 mode and set the default for new windows to UTF-8.ctrl.

-v

Print version information and exit.

-wipe [match]

Like -ls, but remove destroyed sessions instead of marking them dead. If a match is specified, it should be in the same form as the argument to the -r option.

-x

Attach to a session that is not detached. Requires multi-display mode.

-X

Run specified command in specified session. Requires multi-display mode, and session must not be password-protected.

Key bindings

screen commands consist of a command character (Ctrl-a by default) followed by another character. For many of the commands, you can also specify the character as Ctrl-character–e.g., Ctrl-a Ctrl-d as well as Ctrl-a d. The default key bindings are listed here. You can change the bindings for yourself in the $HOME/.screenrc configuration file, or for all users in /etc/screenrc. The term in parentheses that follows the description is the equivalent configuration-file command for changing the key binding.

Ctrl-a ‘

Prompt for window name or number to switch to. (select)

Ctrl-a “

List all windows for selection. (windowlist -b)

Ctrl-a num

Switch to window num, where num is a digit in the range 0-9 or - (the blank window). (select num)

Ctrl-a Tab

Switch input focus to next region. (focus)

Ctrl-a Ctrl-a

Toggle to previously displayed window. (other)

Ctrl-a a

Send the command character (Ctrl-a) to the window. (meta)

Ctrl-a A

Prompt user to enter a name for the current window. (title)

Ctrl-a b

Send a break to the window. (break)

Ctrl-a B

Reopen the terminal line and send a break. (pow-break)

Ctrl-a c

Create a new window with a shell and switch to it. (screen)

Ctrl-a C

Clear the screen. (clear)

Ctrl-a d

Detach screen from this terminal. (detach)

Ctrl-a D D

Detach and log out. (pow-detach)

Ctrl-a f

Toggle flow control between on, off, and auto. (flow)

Ctrl-a F

Resize window to current region size. (fit)

Ctrl-a Ctrl-g

Toggle visual bell mode. (vbell)

Ctrl-a h

Write contents of the current window to the file hardcopy.n. (hardcopy)

Ctrl-a H

Begin/end logging of the current window to the file screenlog.n. (log)

Ctrl-a i

Show information about this window. (info)

Ctrl-a k

Kill current window. (kill)

Ctrl-a l

Refresh current window. (redisplay)

Ctrl-a L

Toggle window’s login slot. Requires that screen be configured to update the utmp database. (login)

Ctrl-a m

Redisplay last message. (lastmsg)

Ctrl-a M

Toggle monitoring of the current window. (monitor)

Ctrl-a Space

Ctrl-a n

Switch to next window. (next)

Ctrl-a N

Show number and title of current window. (number)

Ctrl-a Backspace

Ctrl-a h

Ctrl-a p

Switch to previous window. (prev)

Ctrl-a q

Send a start signal (associated with Ctrl-q by terminals) to current window. (xon)

Ctrl-a Q

Delete all regions except the current one. (only)

Ctrl-a r

Toggle current window’s line-wrap setting. (wrap)

Ctrl-a s

Send a stop signal (associated with Ctrl-s by terminals) to current window. (xoff)

Ctrl-a S

Split current region into two new regions. (split)

Ctrl-a t

Show system information, including time and date. (time)

Ctrl-a v

Display version information. (version)

Ctrl-a Ctrl-v

Enter digraph for entering characters that can’t normally be entered. (digraph)

Ctrl-a w

List all windows. (windows)

Ctrl-a W

Toggle 80/132 columns. (width)

Ctrl-a x

Lock terminal. (lockscreen)

Ctrl-a X

Kill the current region. (remove)

Ctrl-a z

Suspend screen. (suspend)

Ctrl-a Z

Reset virtual terminal to its “power-on” values. (reset)

Ctrl-a .

Write out a .termcap file. (dumptermcap)

Ctrl-a ?

Show all key bindings. (help)

Ctrl-a Ctrl-\

Kill all windows and terminate screen. (quit)

Ctrl-a :

Enter command-line mode. (colon)

Ctrl-a [

Ctrl-a Esc

Enter copy/scrollback mode. (copy)

Ctrl-a ]

Write contents of the paste buffer to the standard input queue of the current window. (paste)

Ctrl-a {

Ctrl-a }

Copy and paste a previous line. (history)

Ctrl-a >

Write paste buffer to a file. (writebuf)

Ctrl-a <

Read screen-exchange file into paste buffer. (readbuf)

Ctrl-a =

Remove file used by Ctrl-a < and Ctrl-a >. (removebuf)

Ctrl-a ,

Show where screen comes from, where it went to, and why you can use it. (license)

Ctrl-a _

Start/stop monitoring the current window for inactivity. (silence)

Ctrl-a *

List all currently attached displays. (displays)

May 27, 2008

最让人恼火的软件(转自奇客)

Filed under: Uncategorized — Cun Zhang @ 15:09

ZDNet UK的一篇文章列举了10种常见的,但常惹你生气的软件(打印版)。互联网送给你很多玩具,它重写了商业和娱乐的规则。但是你并非不会产生烦恼,实际上它们常常会弄巧成拙,令你痛苦不堪,甚至幻想没有互联网,它从来没有出现过。

 

Adobe Reader:我们只是用它看电子书,但它却像官僚机构一样臃肿,不间断的更新(还要求重启,这是什么道理?)。

Apple:它让微软看起来是个好人。
Windows Update:“立即重启”,“不要关闭电源,直至5项更新完成”,“你需要安装Microsoft Genuine Advantage”,“请在安装前关闭所有应用程序”。
RealPlayer:犯下的罪行罄竹难书,它嵌入的广告比报纸首页还多(其实和国内的许多软件相比,它已算是圣人了)。
Java:它是一种程序语言,但是不甘寂寞,总是想提醒你Sun有多好,并推销OpenOffice,还在你的浏览器上安装Yahoo Toolbar,天底下有这种语言吗?
Yahoo:它设法控制你的邮件、搜索引擎、主页,更别提该死的工具栏了。
Norton Antivirus:就像是你的桌面出现了撒旦。
预先捆绑的软件:一些公司总是想夹带私货,索尼就是其中的王者:悄悄的安装程序,并加入到系统启动项中,或者消耗巨大的资源。
Outlook/Exchange:当免费的web email飞速发展时,它还是不紧不慢,过好多年才更新一次。
Flash:自我感觉良好的播放器。

May 26, 2008

linux使用top命令察看系统进程信息

Filed under: Linux — Tags: , — Cun Zhang @ 12:40

top命令
top命令和ps命令的基本作用是相同的,显示系统当前的进程和其他状况;但是top是一个动态显示过程,即可以通过用户按键来不断刷新当前状态。如? 前台执行该命令,它将独占前台,直到用户终止该程序为止。

比较准确的说,top命令提供了实时的对系统处理器的状态监视。它将显示系统中CPU最“敏感”的任务列表。该命令可以按CPU使用。内存使用和执行时 间对任务进行排序;而且该命令的很多特性都可以通过交互式命令或者在个人定制文件中进行设定。在后面的介绍中将把命令参数和交互命令分开讲述。

下面是该命令的语法格式:

top [-] [d delay] [q] [c] [s] [S] [i]

d 指定每两次屏幕信息刷新之间的时间间隔。当然用户可以使用s交互命令来改变之。

q 该选项将使top没有任何延迟的进行刷新。如果调用程序有超级用户权限,那么top将以尽可能高的优先级运行。

S 指定累计模式。

s 使top命令在安全模式中运行。这将去除交互命令所带来的潜在危险。

i 使top不显示任何闲置或者僵死进程。

c 显示整个命令行而不只是显示命令名

top命令显示的项目很多,默认值是每5秒更新一次,当然这是可以设置的。显示的各项目为:

uptime 该项显示的是系统启动时间、已经运行的时间和三个平均负载值(最近1秒,5秒,15秒的负载值)。

processes 自最近一次刷新以来的运行进程总数。当然这些进程被分为正在运行的,休眠的,停止的等很多种类。进程和状态显示可以通过交互命令t来实现。

CPU states 显示用户模式,系统模式,优先级进程(只有优先级为负的列入考虑)和闲置等各种情况所占用CPU时间的百分比。优先级进程所消耗的时间也被列入到用户和系统的时间中,所以总的百分比将大于100%。

Mem 内存使用情况统计,其中包括总的可用内存,空闲内存,已用内存,共享内存和缓存所占内存的情况。

Swap 交换空间统计,其中包括总的交换空间,可用交换空间,已用交换空间。

PID 每个进程的ID。

PPID 每个进程的父进程ID。

UID 每个进程所有者的UID 。

USER 每个进程所有者的用户名。

PRI 每个进程的优先级别。

NI 该进程的优先级值。

SIZE 该进程的代码大小加上数据大小再加上堆栈空间大小的总数。单位是KB。

TSIZE 该进程的代码大小。对于内核进程这是一个很奇怪的值。

DSIZE 数据和堆栈的大小。

TRS 文本驻留大小。

D 被标记为“不干净”的页项目。

LIB 使用的库页的大小。对于ELF进程没有作用。

RES 该进程占用的物理内存的总数量,单位是KB。

SHARE 该进程使用共享内存的数量。

STAT 该进程的状态。其中S代表休眠状态;D代表不可中断的休眠状态;R代表运行状态;Z代表僵死状态;T代表停止或跟踪状态。

TIME 该进程自启动以来所占用的总CPU时间。如果进入的是累计模式,那么该时间还包括这个进程子进程所占用的时间。且标题会变成CTIME。

%CPU 该进程自最近一次刷新以来所占用的CPU时间和总时间的百分比。

%MEM 该进程占用的物理内存占总内存的百分比。

COMMAND 该进程的命令名称,如果一行显示不下,则会进行截取。内存中的进程会有一个完整的命令行。

下面介绍在top命令执行过程中可以使用的一些交互命令。从使用角度来看,熟练的掌握这些命令比掌握选项还重要一些。这些命令都是单字母的,如果在命令行选项中使用了s选项,则可能其中一些命令会被屏蔽掉。

$#@60;空格立即刷新显示。

Ctrl+L 擦除并且重写屏幕。

h或者? 显示帮助画面,给出一些简短的命令总结说明。

k 终止一个进程。系统将提示用户输入需要终止的进程PID,以及需要发送给该进程什么样的信号。一般的终止进程可以使用15信号;如果不能正常结束那就使用信号9强制结束该进程。默认值是信号15。在安全模式中此命令被屏蔽。

i 忽略闲置和僵死进程。这是一个开关式命令。

q 退出程序。

r 重新安排一个进程的优先级别。系统提示用户输入需要改变的进程PID以及枰?柚玫慕?逃畔燃吨怠J淙胍桓稣?到?褂畔燃督档停?粗?蚩梢允垢媒?逃涤懈?叩挠畔热āD?现凳?0。

S 切换到累计模式。

s 改变两次刷新之间的延迟时间。系统将提示用户输入新的时间,单位为s。如果有小数,就换算成m s。输入0值则系统将不断刷新,默认值是5 s。需要注意的是如果设置太小的时间,很可能会引起不断刷新,从而根本来不及看清显示的情况,而且系统负载也会大大增加。

f或者F 从当前显示中添加或者删除项目。

o或者O 改变显示项目的顺序。

l 切换显示平均负载和启动时间信息。

m 切换显示内存信息。

t 切换显示进程和CPU状态信息。

c 切换显示命令名称和完整命令行。

M 根据驻留内存大小进行排序。

P 根据CPU使用百分比大小进行排序。

T 根据时间/累计时间进行排序。

W 将当前设置写入~/.toprc文件中。这是写top配置文件的推荐方法。

从上面的介绍中可以看到,top命令是一个功能十分强大的监控系统的工具,尤其对于系统管理员而言更是如此。一般的用户可能会觉得ps命令其实就够用了,但是top命令的强劲功能确实提供了不少方便。下面来看看实际使用的情况。

[例23] 键入top命令查看系统状况

$ top

1:55pm up 7 min, 4 user, load average:0.07,0.09,0.06

29 processes:28 sleeping, 1 running, 0 zombie, 0 stopped

CPU states: 4.5% user, 3.6% system, 0.0% nice, 91.9% idle

Mem: 38916K av, 18564K used, 20352K free, 11660K shrd, 1220K buff

Swap: 33228K av, 0K used, 33228K free, 11820K cached

PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND

363 root 14 0 708 708 552 R 0 8.1 1.8 0:00 top

1 root 0 0 404 404 344 S 0 0.0 1.0 0:03 init

2 root 0 0 0 0 0 SW 0 0.0 0.0 0:00 kflushd

3 root -12 -12 0 0 0 SW 0 0.0 0.0 0:00 kswapd

4 root 0 0 0 0 0 SW 0 0.0 0.0 0:00 md_thread

5 root 0 0 0 0 0 SW 0 0.0 0.0 0:00 md_thread

312 root 1 0 636 636 488 S 0 0.0 1.6 0:00 telnet

285 root 6 0 1140 1140 804 S 0 0.0 2.9 0.00 bash

286 root 0 0 1048 1048 792 S 0 0.0 2.6 0.00 bash

25 root 0 0 364 364 312 S 0 0.0 0.9 0.00 kerneld

153 root 0 0 456 456 372 S 0 0.0 1.1 0.00 syslogd

160 root 0 0 552 552 344 S 0 0.0 1.4 0.00 klogd

169 daemon 0 0 416 416 340 S 0 0.0 1.0 0.00 atd

178 root 2 0 496 496 412 S 0 0.0 1.2 0.00 crond

187 bin 0 0 352 352 284 S 0 0.0 0.9 0.00 portmap

232 root 0 0 500 500 412 S 0 0.0 1.2 0.00 rpc.mountd

206 root 0 0 412 412 344 S 0 0.0 1.0 0.00 inetd

215 root 0 0 436 436 360 S 0 0.0 1.1 0.00 icmplog

第一行的项目依次为当前时间、系统启动时间、当前系统登录用户数目、平均负载。第二行为进程情况,依次为进程总数、休眠进程数、运行进程数、僵死进程 数、终止进程数。第三行为CPU状态,依次为用户占用、系统占用、优先进程占用、闲置进程占用。第四行为内存状态,依次为平均可用内存、已用内存、空闲内 存、共享内存、缓存使用内存。第五行为交换状态,依次为平均可用交换容量、已用容量、闲置容量、高速缓存容量。然后下面就是和ps相仿的各进程情况列表 了。

总的来说,top命令的功能强于ps,但需要长久占用前台,所以用户应该根据自己的情况来使用这个命令。

在matlab里读取多个文件的数据(转)

Filed under: Math — Tags: , , , — Cun Zhang @ 11:33

注:在Octave里运行很多程序,然后将每个程序的结果存到不同的文件里。上网上找到这篇文章,终于将那个问题搞定。谢谢那位朋友的帖子!特转载之。

原文地址:http://www.myclub2.com/blog/realghost/archive/2007/09/23/45972.html

在一个matlab的学习群里,有人提出了这么一个问题:在matlab里如何读取多信文件的数据,例如,有许多数据,存放在不同的txt文件里。

我的办法是把这些文件的文件名按一定的规律命名,假如有一百个数据文件,则可以把这些文件分别命名为:filename1.txt,filename2.txt,…,fielname100.txt,在读取的时候则可以使用循环:

for i = 1:100

fileName = ['filename' num2str(i) '.txt'];

x = load(fileName);

end

但另一位朋友给出了另一个解决的办法,无需对数据文件的文件名进行修改,就是文件名无须有规律,他的办法是:

A = dir(fullfile(’d:\datafile’,'*.txt’));

这个语句是把存放数据文件的目录d:\datafile下的所有txt文件列出来,并把这些文件名的信息存放到一个变量A中,A是一个结构体变量,只要对A进行循环就可以读取到所有文件的数据了。

所谓人外有人,山外有山,我真是受教了,特写此文以记录此法。

附:help fullfile

help fullfile
FULLFILE Build full filename from parts.
FULLFILE(D1,D2, … ,FILE) builds a full file name from the
directories D1,D2, etc and filename FILE specified. This is
conceptually equivalent to

F = [D1 filesep D2 filesep ... filesep FILE]

except that care is taken to handle the cases where the directory
parts D1, D2, etc. may begin or end in a filesep. Specify FILE = ”
to build a pathname from parts.

Examples
To build platform dependent paths to files:
fullfile(matlabroot,’toolbox’,'matlab’,'general’,'Contents.m’)

To build platform dependent paths to a directory:
addpath(fullfile(matlabroot,’toolbox’,'matlab’,”))

See also filesep, pathsep, fileparts.
Reference page in Help browser
doc fullfile

Older Posts »

Powered by WordPress