2009年12月11日金曜日
2009年11月24日火曜日
The Command-line HTTP Client Tool
The Windows 2000 Resource Kit
If you need to access a Web site from the command line or a batch file, the Command-line HTTP Client tool (httpcmd.exe) can help. This Microsoft Windows 2000 Resource Kit utility reads its input commands from simple text files, many of which are generic so that you can use them with several Web sites.
Occasionally, you might require a tool that can access a Web site or application from the command line. For example, you might want to access a site from a batch file or test to see whether a site is running. You might also need to copy the HTML content from a Web page and save it to disk. If you perform tasks such as these repeatedly, consider httpcmd.exe.
Creating and Modifying Input Files
Before you can use httpcmd.exe, you need to create an input (.req) file. Input files contain the HTTP commands you use to access a Web site. You must specify the Web site or server address on the command line.
You can create simple or complex input files. For example, I copied the contents of the default.req file
GET /default.htm HTTP/1.0
(which is installed with the resource kit) to getdefault.req. To use this input file with the HTTP command, I opened a command prompt and issued the command
httpcmd www.32x.com getdefault.req
This command executes the HTTP command and accesses default.htm from my Web site—http://www.32x.com. I could access default.htm from any other Web site by reissuing the command with a new Web site address or server.
After the command executes, it displays the returned HTML or HTTP stream to the command prompt display (STDOUT). To save this output, use the Redirect option with the command
httpcmd www.32x.com getdefault.req > 32xresults.htm
This command sends the output to the 32xresults.htm file. If you open 32xresults.htm in a browser, it displays the default.htm page from the Web site. In this way, you can use the Command-line HTTP Client tool to retrieve a Web page and save it to disk.
The syntax of the HTTP command includes several options, as Table 1 shows. For example, use the input file
//
// Tests If-Modified-Since headers
//
GET /default.htm HTTP/1.0
If-Modified-Since: Sun, 17 Sep 2000 08:00:00 GMT
to retrieve a page only if it's been modified after a given date. When you execute the HTTP command with this file, a page will appear only if it's been modified after Sunday, September 17, 2000, at 8:00 a.m. Greenwich Mean Time (GMT). If you use this command against http://www.32x.com, you'll receive the display that Figure 1, page 16, shows. In the first line, error 304 Not modified shows that no one has modified the page since the request date. The second line shows the type of server the site uses. The third line shows the date and time of the request. The fourth line shows the ETag, which is an HTTP header tag, and the fifth line shows the content length as 0. The content length is 0 because the file wasn't modified between September 17, 2000, and the request date in the input file.
Next, change the input file contents to
GET /default.htm HTTP/1.0
If-Modified-Since: Sun, 4 June 2000 08:00:00 GMT
and save the input file to a new file. When you run the command with the new input file, you receive the display that Figure 2 shows, followed by the HTML content. The new lines in the output indicate that the request was successful. Content-Type is now text/html, the Accept-Ranges setting shows bytes, and Content-Length now shows the length of the HTML content returned.
The folder in which you install the resource kit (by default, C:\program files\resource kit) contains several sample .req files. To better understand what you can do with the HTTP command, run these .req files against a familiar Web site, such as http://www.microsoft.com. Then, you can change entries, such as the file date, in the input file and see the results. Some of the sample .req files require input or executable files and won't work unless you customize them for your files. Most of the sample .req files require tweaking to be useful.
Next Month
You can use the Command-line HTTP Client tool for many tasks, such as automating data retrieval from a site or service or testing services. You can also use the command in a batch file to test a site under development. Copy the sample .req files to a new folder, and experiment with them. Make changes to the files and test them, but be careful of syntax when you make your changes. For example, checking for a file-modified date works only if you format your date correctly (see ifmod.req for examples of date requests).
Next month, I'll examine the HTTP Monitoring tool. With that utility, you can monitor Web sites and report the results to a file or the event log.
End of Article
If you need to access a Web site from the command line or a batch file, the Command-line HTTP Client tool (httpcmd.exe) can help. This Microsoft Windows 2000 Resource Kit utility reads its input commands from simple text files, many of which are generic so that you can use them with several Web sites.
Occasionally, you might require a tool that can access a Web site or application from the command line. For example, you might want to access a site from a batch file or test to see whether a site is running. You might also need to copy the HTML content from a Web page and save it to disk. If you perform tasks such as these repeatedly, consider httpcmd.exe.
Creating and Modifying Input Files
Before you can use httpcmd.exe, you need to create an input (.req) file. Input files contain the HTTP commands you use to access a Web site. You must specify the Web site or server address on the command line.
You can create simple or complex input files. For example, I copied the contents of the default.req file
GET /default.htm HTTP/1.0
(which is installed with the resource kit) to getdefault.req. To use this input file with the HTTP command, I opened a command prompt and issued the command
httpcmd www.32x.com getdefault.req
This command executes the HTTP command and accesses default.htm from my Web site—http://www.32x.com. I could access default.htm from any other Web site by reissuing the command with a new Web site address or server.
After the command executes, it displays the returned HTML or HTTP stream to the command prompt display (STDOUT). To save this output, use the Redirect option with the command
httpcmd www.32x.com getdefault.req > 32xresults.htm
This command sends the output to the 32xresults.htm file. If you open 32xresults.htm in a browser, it displays the default.htm page from the Web site. In this way, you can use the Command-line HTTP Client tool to retrieve a Web page and save it to disk.
The syntax of the HTTP command includes several options, as Table 1 shows. For example, use the input file
//
// Tests If-Modified-Since headers
//
GET /default.htm HTTP/1.0
If-Modified-Since: Sun, 17 Sep 2000 08:00:00 GMT
to retrieve a page only if it's been modified after a given date. When you execute the HTTP command with this file, a page will appear only if it's been modified after Sunday, September 17, 2000, at 8:00 a.m. Greenwich Mean Time (GMT). If you use this command against http://www.32x.com, you'll receive the display that Figure 1, page 16, shows. In the first line, error 304 Not modified shows that no one has modified the page since the request date. The second line shows the type of server the site uses. The third line shows the date and time of the request. The fourth line shows the ETag, which is an HTTP header tag, and the fifth line shows the content length as 0. The content length is 0 because the file wasn't modified between September 17, 2000, and the request date in the input file.
Next, change the input file contents to
GET /default.htm HTTP/1.0
If-Modified-Since: Sun, 4 June 2000 08:00:00 GMT
and save the input file to a new file. When you run the command with the new input file, you receive the display that Figure 2 shows, followed by the HTML content. The new lines in the output indicate that the request was successful. Content-Type is now text/html, the Accept-Ranges setting shows bytes, and Content-Length now shows the length of the HTML content returned.
The folder in which you install the resource kit (by default, C:\program files\resource kit) contains several sample .req files. To better understand what you can do with the HTTP command, run these .req files against a familiar Web site, such as http://www.microsoft.com. Then, you can change entries, such as the file date, in the input file and see the results. Some of the sample .req files require input or executable files and won't work unless you customize them for your files. Most of the sample .req files require tweaking to be useful.
Next Month
You can use the Command-line HTTP Client tool for many tasks, such as automating data retrieval from a site or service or testing services. You can also use the command in a batch file to test a site under development. Copy the sample .req files to a new folder, and experiment with them. Make changes to the files and test them, but be careful of syntax when you make your changes. For example, checking for a file-modified date works only if you format your date correctly (see ifmod.req for examples of date requests).
Next month, I'll examine the HTTP Monitoring tool. With that utility, you can monitor Web sites and report the results to a file or the event log.
End of Article
2009年11月4日水曜日
2009年10月5日月曜日
OpenWrt Samba server
All you need is :
# An OpenWRT Compatible device
# Extrenal storage like an USB Harddrive or USB Memory Stick or SD Card with some 50-100 MB space.(For the WL-HDD you just need a regular Harddrive)
The tutorial is based on you having mounted the external storage on /opt !
Installing and Configuring Samba
Installing Samba is easy using Nicos testing packages:
ipkg install http://openwrt.org/downloads/people/nico/testing/mipsel/packages/samba_2.0.10-1_mipsel.ipk
Configuring is done easily by creating the file /etc/samba/smb.conf.
An example of a (simple) working config file could be:
workgroup = WORKGROUP
server string = OpenWRT Samba Server
wins support = no
dns proxy = no
name resolve order = lmhosts hosts bcast
log file = /opt/var/log/samba/log.%m
max log size = 1000
syslog = 0
security = share
encrypt passwords = true
obey pam restrictions = yes
guest account = nobody
passwd program = /usr/bin/passwd %u
load printers = no
[SambaShare]
comment = /opt/samba
path = /opt/samba
browseable = yes
public = yes
guest ok = yes
writeable = yes
Now create the shared directory you defined in the config file, and make it writable by everyone.
mkdir -p /opt/samba
chmod 777 /opt/samba
Now create a startup file called /etc/init.d/S50samba
Mine looks like:
#!/bin/sh
case $1 in
start)
nmbd -D
smbd -D
;;
stop)
killall nmbd
killall smbd
;;
*)
echo "usage: $0 (start|stop)"
exit 1
esac
exit $?
Dont forget to make the file executable :
chmod +x /etc/init.d/S50samba
Now you can try to start your samba server:
ps |grep "mbd"
If your Samba server is running, this should give you something like:
2170 root 908 S nmbd -D
2172 root 924 S smbd -D
2176 root 316 S grep mbd
Now you should be able to browse your share called "SambaShare" from any computer that is a member of "WORKGROUP" (the default workgroup name in Windows).
All users are able to both read and write on the share, since users all use the "nobody" account.
# An OpenWRT Compatible device
# Extrenal storage like an USB Harddrive or USB Memory Stick or SD Card with some 50-100 MB space.(For the WL-HDD you just need a regular Harddrive)
The tutorial is based on you having mounted the external storage on /opt !
Installing and Configuring Samba
Installing Samba is easy using Nicos testing packages:
ipkg install http://openwrt.org/downloads/people/nico/testing/mipsel/packages/samba_2.0.10-1_mipsel.ipk
Configuring is done easily by creating the file /etc/samba/smb.conf.
An example of a (simple) working config file could be:
workgroup = WORKGROUP
server string = OpenWRT Samba Server
wins support = no
dns proxy = no
name resolve order = lmhosts hosts bcast
log file = /opt/var/log/samba/log.%m
max log size = 1000
syslog = 0
security = share
encrypt passwords = true
obey pam restrictions = yes
guest account = nobody
passwd program = /usr/bin/passwd %u
load printers = no
[SambaShare]
comment = /opt/samba
path = /opt/samba
browseable = yes
public = yes
guest ok = yes
writeable = yes
Now create the shared directory you defined in the config file, and make it writable by everyone.
mkdir -p /opt/samba
chmod 777 /opt/samba
Now create a startup file called /etc/init.d/S50samba
Mine looks like:
#!/bin/sh
case $1 in
start)
nmbd -D
smbd -D
;;
stop)
killall nmbd
killall smbd
;;
*)
echo "usage: $0 (start|stop)"
exit 1
esac
exit $?
Dont forget to make the file executable :
chmod +x /etc/init.d/S50samba
Now you can try to start your samba server:
ps |grep "mbd"
If your Samba server is running, this should give you something like:
2170 root 908 S nmbd -D
2172 root 924 S smbd -D
2176 root 316 S grep mbd
Now you should be able to browse your share called "SambaShare" from any computer that is a member of "WORKGROUP" (the default workgroup name in Windows).
All users are able to both read and write on the share, since users all use the "nobody" account.
2009年9月28日月曜日
หลักการวางแผนการเงิน 10 ข้อ
ข้อคิดในการเริ่มวางแผนการ เงินที่สถาบันนักวางแผนการเงินของสหราชอาณาจักรรวบรวมไว้ 10 ข้อ ซึ่งก็คล้ายๆ กับของสมาคมนักวางแผนการเงินไทย ดังนี้
1. ตั้งเป้าหมายชีวิต ว่า ท่านจะจัดลำดับความสำคัญของสิ่งต่างๆ ในชีวิตอย่างไร โดยแยกเป็น เป้าหมายระยะสั้น เช่น วางแผนไปเที่ยวในปีหน้า ระยะปานกลาง เช่น มีลูก มีธุรกิจของตัวเอง และระยะยาว เช่น แผนเกษียณอายุงาน
2. รู้ความมั่งคั่งสุทธิของตนเอง โดยการหามูลค่าของสินทรัพย์ทั้งหมด หักด้วยหนี้สินทั้งหมด และตั้งเป้าหมายเพิ่มความมั่งคั่งสุทธิในแต่ละช่วงเวลาของชีวิต
3. จัดสรรงบประมาณ และพยายามใช้จ่ายตามงบประมาณนั้น โดยท่านควรจะใช้จ่ายน้อยกว่ารายได้ของท่าน แต่ถ้าท่านใช้จ่ายมากกว่ารายได้ ต้องตัดรายจ่ายลง หรือต้องเพิ่มรายได้ด้วยการทำงานเพิ่ม ไม่ควรกู้ยืมมาจ่ายค่าซื้อของหรือเพื่อไปท่องเที่ยว
4. หนี้สิน กู้ยืมเงินเฉพาะในยามที่ต้องการจริงๆ และก่อนที่จะกู้เงินหรือใช้เงินจากบัญชีบัตรเครดิต ต้องรู้อัตราดอกเบี้ยและค่าธรรมเนียมที่จะต้องจ่าย เพราะเมื่อนำดอกเบี้ยมารวมกับค่าสินค้าแล้ว สินค้าที่ซื้ออาจจะมีราคาแพงมากๆ เมื่อมีหนี้ควรพยายามใช้คืนหนี้ให้เร็ว
5. ฝากเงินไว้ใช้ในยามฉุกเฉิน ในสัดส่วนเท่ากับรายจ่ายประมาณ 2-3 เดือน (จำเป็นที่จะต้องทำแม้ว่าท่านจะต้องการเงินไปจ่ายคืนหนี้ที่อัตราดอกเบี้ย สูงๆ ก็ตาม)
6. ออม! เมื่อจ่ายคืนหนี้อัตราดอกเบี้ยสูงหมด และมีเงินฝากไว้ใช้ยามฉุกเฉินแล้ว ท่านต้องเริ่มออมทุกๆ เดือนเพื่อบรรลุเป้าหมายระยะสั้นและระยะปานกลาง เช่น ซื้อรถใหม่ ไปเที่ยว ซ่อมแซมบ้าน ฯลฯ
7. ป้องกันตัวเองก่อน ต้องป้องกันตัวเองและทรัพย์สินจากเหตุการณ์ไม่คาดฝัน เพื่อให้แน่ใจว่าท่านและครอบครัวมีเงินไว้ชำระค่าหมอ ค่ายา อุบัติเหตุ หรือมีเงินผ่อนชำระหนี้สินกรณีที่ผู้หารายได้หลักของครอบครัวจากไปก่อนวัย อันควร ควรป้องกันทั้งทรัพย์สินหลักๆ เช่น บ้านและรถยนต์ และจัดทำพินัยกรรม
8. วางแผนเกษียณ แต่เนิ่นๆ ออมให้มากกว่าที่ถูกบังคับออมในกองทุนสำรองเลี้ยงชีพ แม้ท่านจะยังมีภาระหนี้อยู่ก็ตาม
9. การลงทุนไม่ใช่เฉพาะสำหรับคนรวยเท่านั้น ทุกคนควรจะลงทุน การลงทุนช่วยเปิดโอกาสให้เงินของท่านทำงานให้ท่านหนักขึ้น ในระยะยาว ให้พิจารณาการลงทุนที่ไม่เสียภาษีจากผลตอบแทน หรือเสียภาษีน้อยด้วย
10. บอกต่อ สอนเรื่องการเงินให้บุตรหลานของท่าน ยิ่งเด็กได้เรียนรู้เร็ว ก็จะยิ่งจัดการการเงินให้ตัวเองได้ดียิ่งขึ้น
1. ตั้งเป้าหมายชีวิต ว่า ท่านจะจัดลำดับความสำคัญของสิ่งต่างๆ ในชีวิตอย่างไร โดยแยกเป็น เป้าหมายระยะสั้น เช่น วางแผนไปเที่ยวในปีหน้า ระยะปานกลาง เช่น มีลูก มีธุรกิจของตัวเอง และระยะยาว เช่น แผนเกษียณอายุงาน
2. รู้ความมั่งคั่งสุทธิของตนเอง โดยการหามูลค่าของสินทรัพย์ทั้งหมด หักด้วยหนี้สินทั้งหมด และตั้งเป้าหมายเพิ่มความมั่งคั่งสุทธิในแต่ละช่วงเวลาของชีวิต
3. จัดสรรงบประมาณ และพยายามใช้จ่ายตามงบประมาณนั้น โดยท่านควรจะใช้จ่ายน้อยกว่ารายได้ของท่าน แต่ถ้าท่านใช้จ่ายมากกว่ารายได้ ต้องตัดรายจ่ายลง หรือต้องเพิ่มรายได้ด้วยการทำงานเพิ่ม ไม่ควรกู้ยืมมาจ่ายค่าซื้อของหรือเพื่อไปท่องเที่ยว
4. หนี้สิน กู้ยืมเงินเฉพาะในยามที่ต้องการจริงๆ และก่อนที่จะกู้เงินหรือใช้เงินจากบัญชีบัตรเครดิต ต้องรู้อัตราดอกเบี้ยและค่าธรรมเนียมที่จะต้องจ่าย เพราะเมื่อนำดอกเบี้ยมารวมกับค่าสินค้าแล้ว สินค้าที่ซื้ออาจจะมีราคาแพงมากๆ เมื่อมีหนี้ควรพยายามใช้คืนหนี้ให้เร็ว
5. ฝากเงินไว้ใช้ในยามฉุกเฉิน ในสัดส่วนเท่ากับรายจ่ายประมาณ 2-3 เดือน (จำเป็นที่จะต้องทำแม้ว่าท่านจะต้องการเงินไปจ่ายคืนหนี้ที่อัตราดอกเบี้ย สูงๆ ก็ตาม)
6. ออม! เมื่อจ่ายคืนหนี้อัตราดอกเบี้ยสูงหมด และมีเงินฝากไว้ใช้ยามฉุกเฉินแล้ว ท่านต้องเริ่มออมทุกๆ เดือนเพื่อบรรลุเป้าหมายระยะสั้นและระยะปานกลาง เช่น ซื้อรถใหม่ ไปเที่ยว ซ่อมแซมบ้าน ฯลฯ
7. ป้องกันตัวเองก่อน ต้องป้องกันตัวเองและทรัพย์สินจากเหตุการณ์ไม่คาดฝัน เพื่อให้แน่ใจว่าท่านและครอบครัวมีเงินไว้ชำระค่าหมอ ค่ายา อุบัติเหตุ หรือมีเงินผ่อนชำระหนี้สินกรณีที่ผู้หารายได้หลักของครอบครัวจากไปก่อนวัย อันควร ควรป้องกันทั้งทรัพย์สินหลักๆ เช่น บ้านและรถยนต์ และจัดทำพินัยกรรม
8. วางแผนเกษียณ แต่เนิ่นๆ ออมให้มากกว่าที่ถูกบังคับออมในกองทุนสำรองเลี้ยงชีพ แม้ท่านจะยังมีภาระหนี้อยู่ก็ตาม
9. การลงทุนไม่ใช่เฉพาะสำหรับคนรวยเท่านั้น ทุกคนควรจะลงทุน การลงทุนช่วยเปิดโอกาสให้เงินของท่านทำงานให้ท่านหนักขึ้น ในระยะยาว ให้พิจารณาการลงทุนที่ไม่เสียภาษีจากผลตอบแทน หรือเสียภาษีน้อยด้วย
10. บอกต่อ สอนเรื่องการเงินให้บุตรหลานของท่าน ยิ่งเด็กได้เรียนรู้เร็ว ก็จะยิ่งจัดการการเงินให้ตัวเองได้ดียิ่งขึ้น
登録:
投稿 (Atom)