Notes: May 2004 Archives

dos2unix, unix2dos 對應指令

| | Comments (0)

dos2unix, unix2dos 用在 DOS <=> UNIX text file 轉換
DOS 格式 0d 0a
UNIX 格式 0a
有時手邊無此工具, 可用功能相同的指令組合
dos2unix:
sed -i "s/\r//" file
or
cat file | col -b > newfile
or
cat file | tr -d "\r" > newfile
cat file | tr -d "\015" > newfile

unix2dos:
sed -i "s/$/\r/" file
sed -i "s/$/\x0d/" file

以上適用 GNU sed, FreeBSD 下的 sed 不適用

[shell] while 讀入檔案表示法

| | Comments (0)

while read i
do
   echo $i
done < file

和下列效果一樣
for i in `cat file`
do
   echo $i
done

php 條件式字串表示

| | Comments (0)

(expression?"string when expression=true":"string when expression=false");

ex.
echo ($a=="yes"?"YES":"NO");
當 $a = yes 時, 會秀出 YES, 否則會秀出 NO

zip tgz bz2 file header

| | Comments (0)

zip
50 4b 03 04 0a

tgz
1f 8b 08 00

bz2
42 5a 68 39 31 41 59 26 53 59 | BZh91AY&SY

md4

| | Comments (0)

openssl dgst -md4 {file}

smb.conf lanman auth

| | Comments (0)

當 samba 有設密碼時
(security = user, encrypt passwords = yes, smb passwd file = smbpasswd)
這個參數要 yes, Windows 9x 才能連

lanman auth (G)
This parameter determines whether or not smbd will attempt to
authenticate users using the LANMAN password hash. If disabled,
only clients which support NT password hashes (e.g. Windows
NT/2000 clients, smbclient, etc... but not Windows 95/98 or the
MS DOS network client) will be able to connect to the Samba
host.

Default : lanman auth = yes

getopt example

| | Comments (0)

getopt 是 shell 裡抓參數的好工具
例: getopt abc:d: 容許參數 -a -b -c -d, -c and -d 後面要接參數

#!/bin/sh
set - `getopt abc:d: $*`
while true
do
case $1 in
-a)
echo option -a
shift
;;
-b)
echo option -b
shift
;;
-c)
echo option -c=$2
shift 2
;;
-d)
echo option -d=$2
shift 2
;;
--)
shift
break
;;
*)
echo "error!"
exit 1
;;
esac
done

執行結果
# ./go -a
option a
# ./go -c jack
option -c=jack
# ./go -b -c jack
option -b
option -c=jack
# ./go -b -c test -d
getopt: option requires an argument -- d
option -b
option -c=test
(使用後面要加參數的 option 會提示)
# ./go -b -c test -f
getopt: invalid option -- f
option -b
option -c=test
(使用未支援的參數會提示)

cd 個人目錄/.mozilla/設定檔名稱/
cd *
rm lock


cd /root/.thunderbird/default
cd 6srdw22r.slt
rm lock

postfix canonical

| | Comments (0)

這個表格重寫 user@somesite 成 other@othesite

在 main.cf 加入 canonical_maps = hash:/etc/postfix/canonical

例一:將 alias name 重寫成 canonical name
test@mail.teco-ia.com.tw test@teco-ia.com.tw
(From: To: 均會重寫)
例二: 當成 forward 使用
test other@othesite

postmap /etc/postfix/canonical 更新 canonical.db
postfix reload 後生效

ref: http://www.laushu.idv.tw/apple/teach/mail_server/postfix_b.html

Pages

March 2008

Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          

About this Archive

This page is a archive of entries in the Notes category from May 2004.

Notes: April 2004 is the previous archive.

Notes: June 2004 is the next archive.

Find recent content on the main index or look in the archives to find all content.