Created
February 12, 2016 14:12
-
-
Save ilyaevseev/ba2a5b9faeeb392aeb4e to your computer and use it in GitHub Desktop.
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/sh | |
# http://vk.com/wall403284_81744 | |
SRCURL="http://transport.orgp.spb.ru/Portal/transport/internalapi/gtfs/realtime/vehicle?bbox=30.32,59.84,30.33,59.85&transports=bus,trolley,tram,ship&routeIDs=1329" | |
DESTURL="ftp://volokhonsky:[email protected]/folder1" | |
MAILTO="[email protected]" | |
MYNAME="${0##*/}" | |
LOGFILE="/tmp/$MYNAME.log" | |
FNAME="$(date +%Y-%m-%d_%H%M%S).bin" | |
Fail() { | |
logger -p "user.err" -t "$MYNAME" -s "$@" | |
echo "$@" | mail -s "$MYNAME failed on $(hostname -f)" $MAILTO | |
exit 1 | |
} | |
lftp -e "get1 $SRCURL -o $FNAME" >"$LOGFILE" 2>&1 || Fail "Cannot download $SRCURL, see $LOGFILE" | |
test -s "$FNAME" || Fail "$SRCURL empty" | |
test -s "$LOGFILE" && Fail "$LOGFILE after downloading is not empty" | |
lftp -e "put $FNAME -o $DESTURL/$FNAME" >"$LOGFILE" 2>&1 || Fail "cannot upload $FNAME to $DESTURL, see $LOGFILE" | |
test -s "$LOGFILE" && Fail "$LOGFILE after uploading is not empty" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment