Вот простой сценарий, который может помочь вам начать работу:
#!/bin/sh
# Make sure a URL is passed first
if [ -z "$1" ]
then
echo "
Pass the full URL to be downloaded. For example:
${0##*/} \"http://websitehttp/website.file.extension\"
If that URL fails, then \"http://website.file.extension\"
will be tried automatically.
"
exit 1
fi
# Attempt download
wget -v "${1}"
# Check for an error and if so, try an alternative download
if [ "$?" != "0" ]
then
url2=`echo ${1} | cut -d '/' -f 4-`
# DEBUG echo "[$url2]"
wget -v "http://${url2}"
fi
echo "Done"
exit 0
python -m HTTPSimpleServer & # Your Python process will now be in the background
serverpid="$!" # Capture its PID so that you can kill it later.
watch -n /path/to/AwesomeTestCommand Arg1 Arg2
# Some time later...
kill "$serverpid" # Make your Python process go away
Попробуйте следующее:
python -m HTTPSimpleServer & watch -n
Похоже на замену; with & должен делать эту работу. Добавьте еще один & в конце, чтобы обе программы работали в фоновом режиме.
Это может звучать как ответ на старый пост, но вы можете просто запустить приложение в nohup
nohup python -m HTTPSimpleServer & watch -n