2014-11-27
2014-11-25
TCL, MAC address increment
set var_mac 001A6A00001F
set var_incr 000000000001
set var_mac2 [ format %X [ expr "0x$var_mac + 0x$var_incr" ] ]
puts $var_mac2
set mac_next "001A$var_mac2"
puts "Next MAC Address is $mac_next"
[OUTPUT]
Next MAC Address is 001A6A000020
[NOTE]
Line 1 to Line 4 產生的值為 Line 5 的 6A000020, 而不是 001A6A00001F, 少了 001A. 很奇怪, 所以才在 Line 7 補上 "001A", 有空再回頭瞭解.
Line 2 $var_incr 也可不用 000000000001, 可以是 1.
2014-11-19
2014-11-18
MD5 Checksum - Linux
- Tool: md5sum
Generate MD5 checksum
Generate a 10M file for test propose.
- # dd if=/dev/zero of=/tmp/test-10M bs=1048576 count=10
- 10+0 records in
- 10+0 records out
- 10485760 bytes (10.0MB) copied, 0.063248 seconds, 158.1MB/s
- # ls -la
- test-10m
Generate MD5checksum
- # cd /tmp
- # md5sum test-10M > test-10M.md5
- # ls -la
- test-10M
- test-10M.md5
- # cat test-10M.md5
- f1c9645dbc14efddc7d8a322685f26eb test-10M
Verify MD5 checksum
Copy test file (test-10m & test-10m.md5) to USB flash
- # mount -t vfat /dev/sda1 /usb
- # cp -rf test-10M test-10M.md5 /usb
- # ls -la /usb
- test-10M
- test-10M.md5
Verify test file in MD5checksum
- # cd /usb
- # md5sum -c test-10m.md5
- test-10M: OK
2014-11-17
TCL, Switch - Select right one through multi-options
set num 3
switch $num {
" 1 " { puts "Monday" }
" 2 " { puts "Tuesday" }
" 3 " { puts "Wednesday" }
" 4 " { puts "Thursday" }
" 5 " { puts "Friday" }
" 6 " { puts "Saturday" }
" 7 " { puts "Sunday" }
" default " { puts "Wrong Value" }
}
[Output]
- Wednesday
TCL, File and Directory
Establish, Delete, Copy & Rename
Detect existing, Size & Type
[ALL Syntax]
Detect existing, Size & Type
[ALL Syntax]
file mkdir "directory_name"
file delete "directory_name"
file delete -force "directory_name"
file delete "file_name"
file copy source-filename target-filename
file copy -force source-filename target-filename
file rename source-filename target-filename
file exists filename
file isdirectory filename
file isfile filename
file size filename
file type filename
TCL, File's Input & Output
[Procedure]
- Open file --> Read/Write file --> Close file
[Syntax]
- Open ==> open filename "access"
- Write ==> puts filename "content"
- Close ==> close filename
- set fd [open "$PATH/$var_sn.tmp.log" a]
- puts $fd "[time_str]: $msg"
- close $fd
[Access Parameter List]
- r : Reading a existing file
- r+ : Reading & Writing a existing file
- w : Empty a existing file, and Writing the content.
- w: Establish a new file, and Writing the content.
- w+ : Empty a existing file, and Writing & Reading the content.
- w+ : Establish a new file, and Writing & Reading the content.
- a : Append the content into the end of existing file, or Establish a new one.
- a+ : Append (Read & Write) the content into the end of existing file, or Establish a new one.
End.
2014-11-05
yEd - Flow Chart tool
Payment: Free
Download place on Official web: http://www.yworks.com/en/downloads.html#yEd
This is a green software that so no need to install it into the Windows and Linux platform.
And JAVA JRE is required before the software installation.
Download place on Official web: http://www.yworks.com/en/downloads.html#yEd
This is a green software that so no need to install it into the Windows and Linux platform.
And JAVA JRE is required before the software installation.
訂閱:
文章 (Atom)