在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:msoap/shell2http开源软件地址:https://github.com/msoap/shell2http开源编程语言:Go 77.8%开源软件介绍:shell2httpHTTP-server to execute shell commands. Designed for development, prototyping or remote control. Settings through two command line arguments, path and shell command. By default bind to :8080. Usage
In the
To setup multiple auth users, you can specify the InstallMacOS:
Using snap (Ubuntu or any Linux distribution with snap):
Notice: the snap-package has its own sandbox with the Download binaries from: releases (OS X/Linux/Windows/RaspberryPi) For Docker users, availeble tags see in Docker Hub:
Build from source (minimum Go version is 1.12):
Examples
HTML calendar for current yearshell2http /cal_html 'echo "<html><body><h1>Calendar</h1>Date: <b>$(date)</b><br><pre>$(cal $(date +%Y))</pre></body></html>"' Get URL parameters (http://localhost:8080/form?from=10&to=100)shell2http -form /form 'echo $v_from, $v_to' CGI scriptsshell2http -cgi /user_agent 'echo $HTTP_USER_AGENT'
shell2http -cgi /set 'touch file; echo "Location: /another_path\n"' # redirect
shell2http -cgi /404 'echo "Status: 404"; echo; echo "404 page"' # custom HTTP code Upload fileshell2http -form \
GET:/form 'echo "<html><body><form method=POST action=/file enctype=multipart/form-data><input type=file name=uplfile><input type=submit></form>"' \
POST:/file 'cat $filepath_uplfile > uploaded_file.dat; echo Ok' Testing upload file with curl:
Simple http-proxy server (for logging all URLs)Setup proxy as "http://localhost:8080/"shell2http -log=/dev/null -cgi / 'echo $REQUEST_URI 1>&2; [ "$REQUEST_METHOD" == "POST" ] && post_param="-d@-"; curl -sL $post_param "$REQUEST_URI" -A "$HTTP_USER_AGENT"' Test slow connection (http://localhost:8080/slow?duration=10)shell2http -form /slow 'sleep ${v_duration:-1}; echo "sleep ${v_duration:-1} seconds"' Proxy with cache in files (for debug with production API with rate limit)get `http://api.url/` as `http://localhost:8080/get?url=http://api.url/`shell2http -form \
/form 'echo "<html><form action=/get>URL: <input name=url><input type=submit>"' \
/get 'MD5=$(printf "%s" $v_url | md5); cat cache_$MD5 || (curl -sL $v_url | tee cache_$MD5)' Remote sound volume control (Mac OS)shell2http /get 'osascript -e "output volume of (get volume settings)"' \
/up 'osascript -e "set volume output volume (($(osascript -e "output volume of (get volume settings)")+10))"' \
/down 'osascript -e "set volume output volume (($(osascript -e "output volume of (get volume settings)")-10))"' Remote control for Vox.app player (Mac OS)shell2http /play_pause 'osascript -e "tell application \"Vox\" to playpause" && echo ok' \
/get_info 'osascript -e "tell application \"Vox\"" -e "\"Artist: \" & artist & \"\n\" & \"Album: \" & album & \"\n\" & \"Track: \" & track" -e "end tell"' Get four random OS X wallpapersshell2http /img 'cat "$(ls "/Library/Desktop Pictures/"*.jpg | ruby -e "puts STDIN.readlines.shuffle[0]")"' \
/wallpapers 'echo "<html><h3>OS X Wallpapers</h3>"; seq 4 | xargs -I@ echo "<img src=/img?@ width=500>"' Mock service with JSON APIcurl "http://some-service/v1/call1" > 1.json
shell2http -cgi /call1 'cat 1.json' /call2 'echo "Content-Type: application/json\n"; echo "{\"error\": \"ok\"}"' Windows exampleReturns value of shell2http.exe -form /test "echo %v_var%" With HTTP headersSend custom HTTP headers: shell2http -cgi / 'echo "Content-Type: application/javascript\n"; echo "{\"error\": \"ok\"}"' On Windows: shell2http.exe -cgi / "echo Content-Type: application/javascript& echo.& echo body" Run from Docker-containerExample of FROM msoap/shell2http
# may be install some alpine packages:
# RUN apk add --no-cache ...
CMD ["/date", "date"] Build and run container:
SSLRun https server:
Generate self-signed certificate:
See also
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论