{"id":281,"date":"2009-08-20T14:48:08","date_gmt":"2009-08-20T14:48:08","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2009\/08\/20\/ftp-transfer-script-for-sgs-logs-files\/"},"modified":"2021-07-24T19:00:51","modified_gmt":"2021-07-24T19:00:51","slug":"ftp-transfer-script-for-sgs-logs-files","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html","title":{"rendered":"FTP Transfer script for SGS logs files"},"content":{"rendered":"
\tBelow is a script will send the latest log file of the SGS (Symantec Gateway) across to an FTP server. You would need to add this to your crontab to run every hour, in the event of multiple log files being generated per day.<\/span><\/p>\n \t#!\/bin\/sh \texport PATH=\/sbin:\/usr\/sbin:\/bin:\/usr\/bin:\/usr\/raptor\/bin\/ftp<\/p>\n \tSERVER="" \tfind \/var\/log\/sg\/oldlogs\/zipped_logs -name logfile\\* -mtime +2 -exec rm -f {} \\; \t\/usr\/raptor\/bin\/ftp -n "${SERVER}" <<END_SCRIPT \tif [ "${RC}" = 0 ] Below is a script will send the latest log file of the SGS (Symantec Gateway) across to an FTP server. You would need to add this to your crontab to run every hour, in the event of multiple log files being generated per day. #!\/bin\/sh # # This script will ftp gzip the latest sgs … Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"yoast_head":"\n
\t#
\t# This script will ftp gzip the latest sgs logfile and send it to your FTP server.
\t#<\/p>\n
\tUSER=""
\tPASSWD=""
\tLOG=`cd \/var\/log\/sg\/oldlogs\/ ; ls logfile* | tail -n1`
\tLOGZIP=`hostname`_`date +%Y%m%d`.gz<\/p>\n
\tmkdir \/var\/log\/sg\/oldlogs\/zipped_logs 2>\/dev\/null
\tgzip -c \/var\/log\/sg\/oldlogs\/"${LOG}" > \/var\/log\/sg\/oldlogs\/zipped_logs\/"${LOGZIP}"<\/p>\n
\tquote USER "${USER}"
\tquote PASS "${PASSWD}"
\tlcd \/var\/log\/sg\/oldlogs\/zipped_logs
\tput "${LOGZIP}"
\tquit
\tEND_SCRIPT
\tRC=$?<\/p>\n
\tthen
\t logger -t FTP_LOG_TRANSFER -p daemon.info "Successfully sent "${LOGZIP}" to "${SERVER}""
\t exit 0
\telse
\t logger -t FTP_LOG_TRANSFER -p daemon.err "Unsuccessfully sent "${LOGZIP}" to "${SERVER}""
\t exit 1
\tfi<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"