2009年12月11日 星期五

Windows 7 磁碟重組


剛裝完Windows7,電腦管理內的磁碟管理已經找不到磁碟重組的工具,但在檔案總管的磁碟機代號上,點選右鍵內容,工具中仍可找到磁碟重組工具(真怕以後找不到了)。用法很簡單,照著指示做就好。
在system32資料夾下,還有一個defrag.exe的command line工具,功能一樣。對command line指令念念不忘的人,就可以使用它來重組。
執行cmd後,直接輸入defrag就可以看到這東西的參數,快速好用!

2009年12月2日 星期三

使用 plink.exe 連至遠端伺服器排程作業

plink 算是 putty 系列 command line 工具(不知道可不可以這樣說),拿來自動化作業時還不錯用!
但是一個重點是它不能在cisco之類的設備上使用。我本來是想使用在公司內的VoIP設備,但是登入後要enable,就不行了,跟cisco設備一樣的地方就是需要進入特權模式。

下載位置 http://the.earth.li/~sgtatham/putty/latest/x86/plink.exe

直接打plink就會出現使用說明,部份參數只能在 ssh 連線下使用

C:\putty>plink
PuTTY Link: command-line connection utility
Release 0.60
Usage: plink [options] [user@]host [command]
("host" can also be a PuTTY saved session name)
Options:
-V print version information and exit
-pgpfp print PGP key fingerprints and exit
-v show verbose messages
-load sessname Load settings from saved session
-ssh -telnet -rlogin -raw
force use of a particular protocol
-P port connect to specified port
-l user connect with specified username
-batch disable all interactive prompts
The following options only apply to SSH connections:
-pw passw login with specified password
-D [listen-IP:]listen-port
Dynamic SOCKS-based port forwarding
-L [listen-IP:]listen-port:host:port
Forward local port to remote address
-R [listen-IP:]listen-port:host:port
Forward remote port to local address
-X -x enable / disable X11 forwarding
-A -a enable / disable agent forwarding
-t -T enable / disable pty allocation
-1 -2 force use of particular protocol version
-4 -6 force use of IPv4 or IPv6
-C enable compression
-i key private key file for authentication
-noagent disable use of Pageant
-agent enable use of Pageant
-m file read remote command(s) from file
-s remote command is an SSH subsystem (SSH-2 only)
-N don't start a shell/command (SSH-2 only)
-nc host:port
open tunnel in place of session (SSH-2 only)

我主要想表達的是 -m 參數,它可以讀取檔案來下指令,
例如:
plink hostname -l username -pw password -m test.txt
(表示登入hostname主機,使用者=username、密碼=password,讀取同目錄下 test.txt 檔案做為指令)

如果 test.txt 內容如下:
cd /home
mkdir test123

結果在 /home 下建立了 test123 目錄。
你當然還可以在 test.txt 下更多的指令、script,例如備份等等…

如果我有弄錯的地方,麻煩留個言給我,謝謝。