Skip to content

Instantly share code, notes, and snippets.

@m2kar
Last active September 19, 2024 03:18
Show Gist options
  • Save m2kar/fed93428d00089a4f80285a341167fd5 to your computer and use it in GitHub Desktop.
Save m2kar/fed93428d00089a4f80285a341167fd5 to your computer and use it in GitHub Desktop.
One-Liner HttpServer Return Command Exec Result
#!/bin/bash
# PROT=18080
# CMD="uptime"
while true; do response=$($CMD); length=$(echo -n "$response" | wc -c); echo -e "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: ${#response}\r\n\r\n$response" | nc -l -p $PORT; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment