-
-
Save hughpearse/6696f62cb94dacf2cdfc97cc84d1753e to your computer and use it in GitHub Desktop.
Simple netcat based one shot http file server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
file=$1 | |
port=$2 | |
if [[ -n "$file" ]] && [[ -n "$port" ]]; then | |
{ echo -ne "HTTP/1.0 200 OK\nContent-Type: application/octet-stream\nContent-Disposition: inline; filename=\"$1\"\nContent-Length: $(wc -c < $file)\n\n"; cat $file; } | nc -l $port | |
else | |
echo "Usage: $(basename $0) <file> <port>" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment