码迷,mamicode.com
首页 > Web开发 > 详细

how to write bash shell CGI under uHTTPd

时间:2017-04-21 17:27:23      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:root   blank   nsf   lock   position   _id   write   map   shel   

how to write bash shell CGI under uHTTPd

Target

Want to provide the smaple RESTful server under uHTTPd on OpenWRT, I select the bash script for a demo

Reference

Bash CGI
Web CGI with Bash Script
PostMan Tester

WWW ROOT Dir on OpenWRT

/www/cgi/test.cgi

  1. #!/bin/sh  
  2. POST_STRING=$(cat)  
  3. echo "Content-type: application/json" 
  4. echo ""  
  5. echo "$POST_STRING"  

uHTTPd passes ‘GET’ paramter to bash by ‘$QUERY_STRING’
uHTTPd passes ‘POST’ conent to bash by STDIN, so bash use ‘POST_STRING=$(cat)’ to get them

Browser Client Access

http://192.168.254.219/cgi-bin/test.cgi


nicephil@gmail.com 2017-4-21

how to write bash shell CGI under uHTTPd

标签:root   blank   nsf   lock   position   _id   write   map   shel   

原文地址:http://www.cnblogs.com/nicephil/p/6744559.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!