{"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
\t#
\t# This script will ftp gzip the latest sgs logfile and send it to your FTP server.
\t#<\/p>\n

\texport PATH=\/sbin:\/usr\/sbin:\/bin:\/usr\/bin:\/usr\/raptor\/bin\/ftp<\/p>\n

\tSERVER=""
\tUSER=""
\tPASSWD=""
\tLOG=`cd \/var\/log\/sg\/oldlogs\/ ; ls logfile* | tail -n1`
\tLOGZIP=`hostname`_`date +%Y%m%d`.gz<\/p>\n

\tfind \/var\/log\/sg\/oldlogs\/zipped_logs -name logfile\\* -mtime +2 -exec rm -f {} \\;
\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

\t\/usr\/raptor\/bin\/ftp -n "${SERVER}" <<END_SCRIPT
\tquote USER "${USER}"
\tquote PASS "${PASSWD}"
\tlcd \/var\/log\/sg\/oldlogs\/zipped_logs
\tput "${LOGZIP}"
\tquit
\tEND_SCRIPT
\tRC=$?<\/p>\n

\tif [ "${RC}" = 0 ]
\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":"

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":"\nFTP Transfer script for SGS logs files - Fir3net<\/title>\n<meta name=\"description\" content=\"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\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"FTP Transfer script for SGS logs files - Fir3net\" \/>\n<meta property=\"og:description\" content=\"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\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html\" \/>\n<meta property=\"og:site_name\" content=\"Fir3net\" \/>\n<meta property=\"article:published_time\" content=\"2009-08-20T14:48:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-24T19:00:51+00:00\" \/>\n<meta name=\"author\" content=\"Rick Donato\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rick Donato\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html\"},\"author\":{\"name\":\"Rick Donato\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037\"},\"headline\":\"FTP Transfer script for SGS logs files\",\"datePublished\":\"2009-08-20T14:48:08+00:00\",\"dateModified\":\"2021-07-24T19:00:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html\"},\"wordCount\":246,\"publisher\":{\"@id\":\"https:\/\/www.fir3net.com\/#organization\"},\"articleSection\":[\"Shell Scripting\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html\",\"url\":\"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html\",\"name\":\"FTP Transfer script for SGS logs files - Fir3net\",\"isPartOf\":{\"@id\":\"https:\/\/www.fir3net.com\/#website\"},\"datePublished\":\"2009-08-20T14:48:08+00:00\",\"dateModified\":\"2021-07-24T19:00:51+00:00\",\"description\":\"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\",\"breadcrumb\":{\"@id\":\"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.fir3net.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Programming\",\"item\":\"https:\/\/www.fir3net.com\/programming\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Shell Scripting\",\"item\":\"https:\/\/www.fir3net.com\/programming\/shell-scripting\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"FTP Transfer script for SGS logs files\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.fir3net.com\/#website\",\"url\":\"https:\/\/www.fir3net.com\/\",\"name\":\"Fir3net\",\"description\":\"Keeping you in the know\",\"publisher\":{\"@id\":\"https:\/\/www.fir3net.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.fir3net.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.fir3net.com\/#organization\",\"name\":\"Fir3net\",\"url\":\"https:\/\/www.fir3net.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png\",\"contentUrl\":\"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png\",\"width\":390,\"height\":88,\"caption\":\"Fir3net\"},\"image\":{\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037\",\"name\":\"Rick Donato\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g\",\"caption\":\"Rick Donato\"},\"description\":\"Rick Donato is a Network Automation Architect\/Evangelist and the founder of Packet Coders.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"FTP Transfer script for SGS logs files - Fir3net","description":"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","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html","og_locale":"en_US","og_type":"article","og_title":"FTP Transfer script for SGS logs files - Fir3net","og_description":"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","og_url":"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html","og_site_name":"Fir3net","article_published_time":"2009-08-20T14:48:08+00:00","article_modified_time":"2021-07-24T19:00:51+00:00","author":"Rick Donato","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rick Donato","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html#article","isPartOf":{"@id":"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html"},"author":{"name":"Rick Donato","@id":"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037"},"headline":"FTP Transfer script for SGS logs files","datePublished":"2009-08-20T14:48:08+00:00","dateModified":"2021-07-24T19:00:51+00:00","mainEntityOfPage":{"@id":"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html"},"wordCount":246,"publisher":{"@id":"https:\/\/www.fir3net.com\/#organization"},"articleSection":["Shell Scripting"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html","url":"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html","name":"FTP Transfer script for SGS logs files - Fir3net","isPartOf":{"@id":"https:\/\/www.fir3net.com\/#website"},"datePublished":"2009-08-20T14:48:08+00:00","dateModified":"2021-07-24T19:00:51+00:00","description":"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","breadcrumb":{"@id":"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/ftp-transfer-script-for-sgs-logs-files.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.fir3net.com\/"},{"@type":"ListItem","position":2,"name":"Programming","item":"https:\/\/www.fir3net.com\/programming"},{"@type":"ListItem","position":3,"name":"Shell Scripting","item":"https:\/\/www.fir3net.com\/programming\/shell-scripting"},{"@type":"ListItem","position":4,"name":"FTP Transfer script for SGS logs files"}]},{"@type":"WebSite","@id":"https:\/\/www.fir3net.com\/#website","url":"https:\/\/www.fir3net.com\/","name":"Fir3net","description":"Keeping you in the know","publisher":{"@id":"https:\/\/www.fir3net.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.fir3net.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.fir3net.com\/#organization","name":"Fir3net","url":"https:\/\/www.fir3net.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png","contentUrl":"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png","width":390,"height":88,"caption":"Fir3net"},"image":{"@id":"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037","name":"Rick Donato","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fir3net.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g","caption":"Rick Donato"},"description":"Rick Donato is a Network Automation Architect\/Evangelist and the founder of Packet Coders."}]}},"_links":{"self":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts\/281"}],"collection":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/comments?post=281"}],"version-history":[{"count":0,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts\/281\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/media?parent=281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/categories?post=281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/tags?post=281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}