Created
July 11, 2011 07:09
-
-
Save wxianfeng/1075411 to your computer and use it in GitHub Desktop.
manage python SimpleHTTPServer for serve page
This file contains hidden or 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 | |
## | |
# start|stop|restart python SimpleHTTPServer | |
# | |
# TODO: | |
# use shell Function for DRY | |
# USAGE: | |
# ./manage_simplehttpserver.sh start|stop|restart | |
# | |
# VIEW: | |
# http://localhost:8000 | |
cd /usr/local/system/projects/entos/external/workspace | |
case $1 in | |
"start" ) | |
echo "start python SimpleHTTPServer" | |
nohup python -m SimpleHTTPServer > /tmp/nohup.out & | |
;; | |
"stop" ) | |
echo "stop python SimpleHTTPServer" | |
kill `ps aux | grep "python -m SimpleHTTPServer"` | grep -v grep | awk '{print $2}' > /dev/null | |
;; | |
"restart" ) | |
echo "restart python SimpleHTTPServer" | |
kill `ps aux | grep "python -m SimpleHTTPServer"` | grep -v grep | awk '{print $2}' > /dev/null | |
nohup python -m SimpleHTTPServer > /tmp/nohup.out & | |
;; | |
*) | |
echo "need start|stop|restart" | |
exit 1 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment