2009年10月31日土曜日

cp -f でも上書き確認が出てしまう

aliasコマンドを実行すると、もしかしたら

cp      cp -i

が表示されませんか?
もしあれば、通常cpと打つと-iオプションが付いて実行されます。
\cpとすると、元のcpコマンドが実行されます。

http://okwave.jp/qa4073724.html

tar ball からファイルの取り出し

tar ball からファイルの取り出し

tar ball (*.tar.gz) から必要なファイルだけを取り出します。
例としまして autorespond-2.0.2.tar.gz からソースファイルを取り出します。

対象の tar ball に含まれるファイルを確認します。 tar コマンドの -t オプションを使用します。

$ tar -ztf autorespond-2.0.2.tar.gz
autorespond-2.0.2/
autorespond-2.0.2/README
autorespond-2.0.2/autorespond.c
autorespond-2.0.2/help_message
autorespond-2.0.2/qmail-auto
autorespond-2.0.2/Makefile

引き数に取り出すファイル (ディレクトリ) 名を指定して tar コマンドを実行します。

$ tar -zxf autorespond-2.0.2.tar.gz autorespond-2.0.2/autorespond.c

コマンド実行後、カレントディレクトリに引き数に指定したファイルだけが展開されます。

$ find .
.
./autorespond-2.0.2.tar.gz
./autorespond-2.0.2
./autorespond-2.0.2/autorespond.c

./autorespond-2.0.2/autorespond.c を取り出して操作は完了です。

http://www.freewheelburning.com/linux/misc.html#tar_t

2009年10月18日日曜日

SEOキーワードツール

http://www.seo-blogs.biz/keyword/

PythonRecipe

項目別にサンプルコードが載っており、お勧めです。
http://lightson.dip.jp/zope/ZWiki/PythonRecipe

[python]日本語のファイルを読み書きする

from codecs import open

in_file = open("before.txt", "r", "iso-2022-jp")
out_file = open("after.txt", "w", "utf-8")

for l in in_file: out_file.write(l)

in_file.close()
out_file.close()

http://d.hatena.ne.jp/yach/20080308#p1

【Python】urllib2 - http headersをセットする。

import urllib2

url = 'http://vsbabu.org/'

txdata = None
txheaders = {
'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)',
'Accept-Language': 'en-us',
'Accept-Encoding': 'gzip, deflate, compress;q=0.9',
'Keep-Alive': '300',
'Connection': 'keep-alive',
'Cache-Control': 'max-age=0',
}
req = urllib2.Request(url, txdata, txheaders)
u = urllib2.urlopen(req)
print u.info()
print u.read()
  

http://vsbabu.org/mt/archives/2003/05/27/urllib2_setting_http_headers.html

urllib2モジュール
http://d.hatena.ne.jp/yumimue/20071231/1199129495

2009年10月12日月曜日

1つのIPで複数のSSLサイトを運用する方法

Listen 443
Listen 444
NameVirtualHost aaa.bbb.ccc.ddd:443
NameVirtualHost aaa.bbb.ccc.ddd:444

<VirtualHost aaa.bbb.ccc.ddd:443>
SSLEngine on
ServerName www.hoge.com
DocumentRoot /www/httpd/www.hoge.com
ServerAdmin webmaster@www.hoge.com
ErrorLog logs/error_log
TransferLog logs/access_log
SSLCertificateFile ssl.crt/www.hoge.com.crt
SSLCertificateKeyFile ssl.key/www.hoge.com.key
</VirtualHost>

<VirtualHost aaa.bbb.ccc.ddd:444>
SSLEngine on
ServerName www.moge.net
DocumentRoot /www/httpd/www.moge.net
ServerAdmin webmaster@www.moge.net
ErrorLog logs/error_log
TransferLog logs/access_log
SSLCertificateFile ssl.crt/www.moge.com.crt
SSLCertificateKeyFile ssl.key/www.moge.com.key
</VirtualHost>
http://q.hatena.ne.jp/1175171428