wget problem [solved]

อยู่ดีดี wget ที่เคยใช้ download อะไรต่างๆนาๆ บน Linux/Unix Server ที่ไม่มี GUI
เกิดใช้ไม่ได้ขึ้นมาซะงั้น  อาการก็เป็นแบบนี้อ่ะ

# wget http://awstats.sourceforge.net/awstats.ftp.urldetail.html
–04:17:37–  http://awstats.sourceforge.net/awstats.ftp.urldetail.html
Resolving awstats.sourceforge.net… 216.34.181.96
Connecting to awstats.sourceforge.net|216.34.181.96|:80… connected.
HTTP request sent, awaiting response…

เหมือนจะ http request ผ่าน แต่ http response กลับไม่มาถึงซะงั้น
ก็เลย ลอง man wget ดูว่าัมันมี option อะไีรให้้ใช้บ้าง เพราะว่า ลอง download file เดียวกันจาก windows server
ที่อยู่บน subnet เดียวกันกับ เจ้า linux server ตัวนี้ มันดัน download ได้ เลยคิดว่าต้องเป็นที่ wget แน่ๆ
อ่าน man ไปเรื่อยๆ ก็เจอกับ –user-agent ที่เอาไว้กำหนดชื่อ ของ browser หรือ http client
ก็เลยลอง wget ด้วย option นี้ดู

# wget –user-agent=”Bankster Browser 1.0″ http://awstats.sourceforge.net/awstats.ftp.urldetail.html
–04:22:42–  http://awstats.sourceforge.net/awstats.ftp.urldetail.html
Resolving awstats.sourceforge.net… 216.34.181.96
Connecting to awstats.sourceforge.net|216.34.181.96|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 238747 (233K) [text/html]
Saving to: `awstats.ftp.urldetail.html.2′

100%[============>] 238,747     79.5K/s   in 2.9s

04:22:46 (79.5 KB/s) - `awstats.ftp.urldetail.html.2′ saved [238747/238747]

เย้ download ได้แล้ว แต่ขี้เกียจพิมพ์ –user-agent=”xx” ทุกครั้งอ่ะ
เลยสร้าง bash script ขึ้นมา โดยเฉพาะเลย ตั้งชื่อว่า fooget ละกัน
ก็ cd /usr/bin/ แล้ว vi fooget

#!/bin/bash
/usr/bin/wget –user-agent=”wget” ${1}

แล้วก็ chmod +x /usr/bin/fooget ให้ execute ได้ เวลาเรียกก็ fooget URL
เสร็จแล้วครับ

This entry was posted in sysadmin and tagged , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. Posted April 7, 2009 at 9:26 pm | Permalink

    test comment

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Tags

  • Pages

  • Categories

  • Archives