Linux Shell Script To Monitor Ftp Server Connection



Similar documents
Network Security In Linux: Scanning and Hacking

How to use FTP Commander

The Einstein Depot server

Downloading and Installing Core FTP

SSH Secure Client (Telnet & SFTP) Installing & Using SSH Secure Shell for Windows Operation Systems

List of FTP commands for the Microsoft command-line FTP client

Using Microsoft Expression Web to Upload Your Site

Syntax: cd <Path> Or cd $<Custom/Standard Top Name>_TOP (In CAPS)

EDGETECH FTP SITE CUSTOMER & VENDOR ACCESS

Using Internet or Windows Explorer to Upload Your Site

Technical Bulletin. SQL Express Backup Utility

The Basics of FTP. Basic Order of Operations: Commands: FTP (File Transfer Protocol) allows a user to transfer files to/from a remote network site.

Automating admin tasks using shell scripts and cron Vijay Kumar Adhikari.

BioSense 2.0. User Community Extension Project. Getting Started With The Data Lockers. Information Contributed by:

Backup and Recovery Procedures

Unix Scripts and Job Scheduling

Using SSH Secure Shell Client for FTP

Remote Storage Area (RSA) Basics

Extending Remote Desktop for Large Installations. Distributed Package Installs

Tor Exit Node Block Scripts

Downloading Files using FTP

enter the administrator user name and password for that domain.

Bash shell programming Part II Control statements

Quick Note 040. Create an SSL Tunnel with Certificates on a Digi TransPort WR router using Protocol Switch.

User s Manual

Using. Microsoft Virtual PC. Page 1

Managing Software and Configurations

Shell Scripts (1) For example: #!/bin/sh If they do not, the user's current shell will be used. Any Unix command can go in a shell script

Linux Syslog Messages in IBM Director

FTP Use. Internal NPS FTP site instructions using Internet Explorer:

CGS 1550 File Transfer Project Revised 3/10/2005

Table of Contents Introduction Supporting Arguments of Sysaxftp File Transfer Commands File System Commands PGP Commands Other Using Commands

Advanced Bash Scripting. Joshua Malone

SFTP SHELL SCRIPT USER GUIDE

Beyond Windows: Using the Linux Servers and the Grid

SFTP Server User Login Instructions. Open Internet explorer and enter the following url:

Adobe Marketing Cloud Using FTP and sftp with the Adobe Marketing Cloud

FTP Image Update for HP Linux Thin Clients

CASHNet Secure File Transfer Instructions

HOW TO CONNECT TO FTP.TARGETANALYSIS.COM USING FILEZILLA. Installation

Introductory Note 711 & 811. Remote Access to Computer Science Linux Files Using Secure Shell Protocols

WinSCP PuTTY as an alternative to F-Secure July 11, 2006

Mapping ITS s File Server Folder to Mosaic Windows to Publish a Website

Moxa Device Manager 2.3 User s Manual

GDC Data Transfer Tool User s Guide. NCI Genomic Data Commons (GDC)

TOPICS IN COMPUTER SECURITY

Tutorial Guide to the IS Unix Service

Insight Video Net. LLC. CMS 2.0. Quick Installation Guide

How to FTP (How to upload files on a web-server)

How to Setup and Connect to an FTP Server Using FileZilla. Part I: Setting up the server

Spectrum Technology Platform. Version 9.0. Spectrum Spatial Administration Guide

Using Windows Task Scheduler instead of the Backup Express Scheduler

In order to upload a VM you need to have a VM image in one of the following formats:

AD Integration & Home Folders

Accessing the FTP Server - User Manual

IIS, FTP Server and Windows

Acronis Backup & Recovery 10 Server for Linux. Update 5. Installation Guide

Using SSH Secure FTP Client INFORMATION TECHNOLOGY SERVICES California State University, Los Angeles Version 2.0 Fall 2008.

Decision Support System to MODEM communications

DiskPulse DISK CHANGE MONITOR

Microsoft Exchange 2007

Installing CPV Lab Version 2.17

FTP Guide - Main Document Secure File Transfer Protocol (SFTP) Instruction Guide

WinSCP Tutorial 01/28/09: Y. Liow

Preventing credit card numbers from escaping your network

Reboot the ExtraHop System and Test Hardware with the Rescue USB Flash Drive

Automating FTP with the CP IT

Connecting to the Hospira FTP Server

FTP Manager. User Guide. July Welcome to AT&T Website Solutions SM

Lab 1 Beginning C Program

Installing IBM Websphere Application Server 7 and 8 on OS4 Enterprise Linux

Managed File Transfer with Universal File Mover

EXTENDED FILE SYSTEM FOR F-SERIES PLC

Moxa Device Manager 2.0 User s Guide

CAPIX Job Scheduler User Guide

MFCF Grad Session 2015

AJ Matrix V5. Installation Manual

2 Advanced Session... Properties 3 Session profile... wizard. 5 Application... preferences. 3 ASCII / Binary... Transfer

Backing up the Embedded Oracle database of a Red Hat Network Satellite

4PSA Total Backup User's Guide. for Plesk and newer versions

imhosted Web Hosting Knowledge Base

Scheduling in SAS 9.3

NAS 109 Using NAS with Linux

Backing Up TestTrack Native Project Databases

Thirty Useful Unix Commands

Quick Reference Guide. Online Courier: FTP. Signing On. Using FTP Pickup. To Access Online Courier.

How to Use JCWHosting Reseller Cloud Storage Solution

1. Product Information

Enterprise Content Management System Monitor 5.1 Agent Debugging Guide Revision CENIT AG Author: Stefan Bettighofer

Online Backup Client User Manual Linux

Installation Guide for WebSphere Application Server (WAS) and its Fix Packs on AIX V5.3L

PuTTY/Cygwin Tutorial. By Ben Meister Written for CS 23, Winter 2007

Reference and Troubleshooting: FTP, IIS, and Firewall Information

1 MAXDATA Modular System Firmware Update

Livezilla How to Install on Shared Hosting By: Jon Manning

State of Michigan Data Exchange Gateway. SSLFTP/SFTP client setup

Exchange / Outlook. Items in the Exchange Folder area will be accessible from any computer anywhere that has Internet access via

Setting Up the Site Licenses

Transcription:

Linux Shell Script To Monitor Ftp Server Connection Main goal of this script is to monitor ftp server. This script is example of how to use ftp command in bash shell. System administrator can use this script to check if ftp server alive and upload there any data/backups. Everytime script create new file, every time with with different md5 sum, after script upload it to ftp server, check md5sum of both files. If md5sum same, that mean that file uploaded to ftpserver successfully. Source : http://linoxide.com/linux-shell-script/monitor-ftp-server/ #!/bin/bash Linux Shell Script #Since there will be few times of using same commands, we will create function with name usage #This function just will show us help menu and will exit from script. function usage { echo Usage: $0 #we tell user which arguments script expect echo ftpserver echo help this help #since not argument of bad argument exit from script exit 1 } #We check if user pass parameters to script.. $# number of parameters passed to script 1

if [ $# -eq 0 ]; then #if no parameters just run function usage that show help menu usage fi while [ $# -gt 0 ] # if user pass some parameters we check each do case $1 in #we take first argument passed by user #if user pass ftpserver as first parameter, so second will be ftp servername and third timeout. ftpserver) HOST=$2;TIMEOUT=$3;shift;; #if user pass help as parameter we just output help menu help) usage;; #if anything else passed just exit from script *) break;; esac shift done #finish of while loop #if user didn t pass ftp servername we show help menu if [ x$host = x ]; then usage fi ## We will use some variables, so in next lines just putting their values. ### Global Variables ORIG_DIR= /tmp/ 2

LOG_FILE= /tmp/ftp.log EMAIL= yevhen.duma@gmail.com #next function will make all checks. function check { #few more variables ####VARIABLES MAXTIMEOUT=300 ORIG_FILE= check.file FTPTIMEOUT= 20 USERNAME= user FOLDER= test PASSWORD= password DATAFOLDER= somefolder #entering temp folder cd $ORIG_DIR #with dd we generate 15Mb file with name from $ORIG_FILE variable and with random content. echo -n Creating file dd if=/dev/urandom of=$orig_dir/$orig_file bs=104857 count=150 > /dev/null 2>&1 echo Done # This tell user that we starting to upload file echo -n Uploading file #we use ftp command to upload file, -i turns off interactive prompting ftp -inv < $LOG_FILE #connect to host open $HOST 3

#connect with user and password user $USERNAME $PASSWORD #cd to some test folder cd $FOLDER/$DATAFOLDER #we tell ftp server that we will use binary mode binary #we will use passive mode passive #this command copy local file to ftp server put $ORIG_FILE #getting size of remove file quote size $ORIG_FILE #closing connection close bye #exit from ftp command EOF #telling user that upload done echo DONE #starting md5 check echo -n Checking MD5 sum #same as above ftp -inv <> $LOG_FILE open $HOST user $USERNAME $PASSWORD cd $FOLDER/$DATAFOLDER passive binary quote size $ORIG_FILE dir 4

#getting md5 of remote file quote XMD5 $ORIG_FILE close bye EOF #getting md5sum value from log file, since it will be in upper case we convert it to lower case with tr MD5=`tail -2 $LOG_FILE head -1 awk {print $2} tr [:upper:] [:lower:]` #we need to connect to remote server once more to delete file ftp -in </dev/null open $HOST user $USERNAME $PASSWORD cd $FOLDER/$DATAFOLDER #this command delete remote file delete $ORIG_FILE close bye EOF #with md5sum command we get md5sum of local file MD5_ORIG=`/usr/bin/md5sum $ORIG_FILE awk {print $1} ` #this line compare md5sums, and variable RESULT will contain message according to check if [ x ${MD5}!= x ${MD5_ORIG} ]; then RESULT= File corrupted. 5

else RESULT= MD5 sum OK fi #this will tell user if file was uploaded successfully or not. echo $RESULT #deleting local file rm $ORIG_FILE #end of function } #to run function (without arguments) check./ftp.sh ftpserver ftp.example.com 20 Uploading file DONE Checking MD5 sum MD5 sum OK Linux Shell Script Result 6