473,388 Members | 1,209 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

HOWTO: Check FTP Site Is Up

Had to write something similar to this for my office. You can adapt to
your use. I just put it on a chron job for every 15 minutes. My bash
script did:

#!/bin/bash
php -d max_execution_time=1000 -q /root/projects/ftptest/ftptester.php

<?php
// ftptester.php:

// use your own mail script -- see my note on this below
require('_sendmail.php');

$FTP_ADDR = 'myftpsite.com';
$FTP_USER = 'special';
$FTP_PASS = 'GhX77ED011FJH';
$FTP_TEST_FILE = 'ftptest.txt';
$FTP_TEST_FILE_PATH = '/root/projects/ftptest';
$SMTP_IP_ADDR = 'mymailserver.com';
$FROM = 'm*@me.com';
$TO = 't*@to.com';
$CC = 'c*@cc.com';
$SUBJECT = 'ALERT: FTP Server Unavailable!';
$MESSAGE = "\n********\n*** ALERT\n\nFTP server $FTP_ADDR is not
responding to file uploads.";
echo "\n\nStarting FTP Server Test...\n";
echo "\t...connecting to $FTP_ADDR\n";
$FTP = ftp_connect($FTP_ADDR);
echo "\t...login with special account\n";
ftp_login($FTP, $FTP_USER, $FTP_PASS);
echo "\t...waiting for latent FTP login\n";
sleep(4);
echo "\t...pushing test file\n";
ftp_put($FTP, $FTP_TEST_FILE, $FTP_TEST_FILE_PATH . '/' .
$FTP_TEST_FILE, FTP_ASCII);
echo "\t...waiting for latest FTP file upload\n";
sleep(4);
echo "\t...checking for file upload success\n";
$nSize = 0;
$nSize = @ ftp_size($FTP, $FTP_TEST_FILE);
if ($nSize < 1) {
echo "\t...PROBLEM! file upload failure\n";
// I don't want to plagarize, so use your own mail script, which
you can
// get easily from PHP.NET website if you search on fputs function
and
// scroll down to see user submitted entries
$mail->Send($SMTP_IP_ADDR, $FROM, $TO, $CC, $SUBJECT, $MESSAGE);
} else {
echo "\t...file upload was a SUCCESS\n";
}
echo "\t...deleting test file\n";
@ ftp_delete($FTP, $FTP_TEST_FILE);
sleep(1);
echo "\t...logging out\n";
ftp_quit($FTP);
echo "Stopped FTP Server Test\n\n";
?>
Jul 17 '05 #1
0 1259

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Logan | last post by:
Several people asked me for the following HOWTO, so I decided to post it here (though it is still very 'alpha' and might contain many (?) mistakes; didn't test what I wrote, but wrote it - more or...
5
by: alejandro lapeyre | last post by:
How can I load / parse an HTML file with .NET? Thanks! Best regards, Alejandro Lapeyre
1
by: RedStain | last post by:
CONTENTS summary setup error messages compensation attempts comment SUMMARY I have an IIS6.0 server which has recently been upgraded to ASP 2.0 as a result of some of the patch requirements...
3
by: Dan Sikorsky | last post by:
How do you get a reference to the LoginStatus control contained in the LoginView control that resides on web.master? I need to determine if the LoginStatus will show a LogOut link(for a logged...
3
by: ATS | last post by:
HOWTO Post to a URL from Server Side ASP script. Please help, I'm trying to make a simple ASP page post to a URL on a seperate web site, and then get the returned HTML into a string which on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.