Last active
May 24, 2019 19:18
-
-
Save vagnerd/b135bdcee3ccd25ddc938303759c6d27 to your computer and use it in GitHub Desktop.
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 | |
## | |
## Run multiple http servers (simple) on tmux | |
## | |
## http://oi66.tinypic.com/15x6dte.jpg - script run on multiple sessions | |
## http://oi63.tinypic.com/28sm0t4.jpg - testing all http servers | |
## https://stackoverflow.com/questions/16325449/how-to-send-a-command-to-all-panes-in-tmux - send command to all panes | |
TMP_HTTPD_DIR="/tmp/httpd_sh_dirs" | |
mkdir -p $TMP_HTTPD_DIR | |
echo "Starting http script server" | |
sleep `shuf -i1-10 -n1` | |
for XPORT in {8085..8092}; do | |
echo "checking available port" | |
sleep `shuf -i1-3 -n1` | |
PORT_USE=`netstat -an --tcp | grep LISTEN | awk '{ print $4 }' | grep $XPORT | cut -d\: -f2` | |
if [ $PORT_USE ]; then | |
echo "$PORT_USE port in use" | |
else | |
mkdir -p $TMP_HTTPD_DIR/$XPORT | |
cd $TMP_HTTPD_DIR/$XPORT | |
echo "WEBSERVER TEST - $XPORT" > index.html | |
python3 -m http.server $XPORT | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment