發表文章

目前顯示的是 12月, 2016的文章

lighttpd + fcgi + C language to do file upload & download

最近使用lighttpd當作http server 搭配fcgi來寫檔案上傳跟下載功能 比較討厭的是,html我完全不會寫啊~~~ 還有fcgi的範例也非常地缺乏 其他語言有很多相關API可以使用 C語言的話就得要自己寫 這邊就講一下是怎樣實現的 首先是下載的部分: 一開始得先要有個html給人下載 可以使用下面的範例             printf("Content-type: text/html\r\n"             printf("<hr />");             printf("<a href='/download/?message'>message</a>");             printf("<hr />"); 當有人點選"message"後會跳轉另一個網址 之後可以利用queryString = getenv("QUERY_STRING"); 去判別server跳轉進來的下載網址 此時需要提供另一個html告訴browser要下載東西             printf("Content-type:   application/octet-stream\r\n");                       printf("Content-Transfer-Encoding: Binary\r\n");             printf("Content-Length: %d\r\n", size);                     ...

在shell script執行某程式之後判斷是否成功

sh /etc/init.d/rcS if [ $? -ne 0 ]; then     /sbin/check 1; fi $?  is the exit status of the most recently-executed command; by convention, 0 means success and anything else indicates failure.