thaiall logomy background

การรอคอยและใช้curlผ่านCommandLine

my town
กฤษฎา ตันเปาว์ | จริยธรรมสำหรับผู้บริหาร | วิจัยคืออะไร | ศูนย์สอบ | KM | SWOT | คำสำคัญ
การรอคอย และ ใช้ curl ผ่าน command line

ผศ.ดร.ทรงเกียรติ ภาวดี

ารรอคอย (Wait) มีหลายวิธีในการเขียน Batch file เช่น Pause, Sleep, Timeout พบว่า ผศ.ดร.ทรงเกียรติ ภาวดี แชร์โค้ดเล่าเรื่องในเฟสบุ๊ค เขียน Batch file เรียกใช้ Timeout ของ DOS , Curl ที่ต้องติดตั้งเพิ่ม และ %RANDOM% ซึ่งเป็น Build-in variable ใน Windows Environment Variables ซึ่ง Timeout มีมาตั้งแต่ Windows 7 (robvanderwoude.com/wait , ss64.com/nt/timeout)

ส่วน Curl นั้นต้องติดตั้งเพิ่มเติม สำหรับใช้ใน Batch file (haxx.se/download haxx.se/windows/) ปกติใช้ Curl ในภาษา PHP เป็นฟังก์ชันที่ผมเลือกใช้แทน file_get_contents ในกรณีที่เครื่องบริการไม่อนุญาต allow_url_fopen ไว้ใน php.ini config file (thaiall.com/php/ , thaiall.com/line/)

DOS> curl http://www.thaiall.com
DOS> curl http://www.thaiall.com > x.htm
DOS> timeout /t 10 (รอสิบวินาที หรือ กดปุ่มใด ๆ ก็หลุดออกมาได้)
DOS> powershell start-sleep -m 2000 (รอ 2000 millisecond หรือ 2 วินาที)
PS> start-sleep -m 3000 (ถ้ารอไม่ได้กด ctrl+c หรือ ctrl+break ปุ่มอื่นไม่หลุด)
Dir : assembly File : batch.htm Topic : timeout_and_curl

Reset | Decode | WVhOelpXMWliSGs9 | WW1GMFkyZ3VhSFJ0
คุณคิดอะไรอยู่
Thaiall.com