By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,869 Members | 1,567 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,869 IT Pros & Developers. It's quick & easy.

HOWTO: Check FTP Site Is Up

P: n/a
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:

php -d max_execution_time=1000 -q /root/projects/ftptest/ftptester.php

// ftptester.php:

// use your own mail script -- see my note on this below

$FTP_ADDR = '';
$FTP_USER = 'special';
$FTP_PASS = 'GhX77ED011FJH';
$FTP_TEST_FILE = 'ftptest.txt';
$FTP_TEST_FILE_PATH = '/root/projects/ftptest';
$FROM = 'm*';
$TO = 't*';
$CC = 'c*';
$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";
echo "\t...pushing test file\n";
echo "\t...waiting for latest FTP file upload\n";
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
// scroll down to see user submitted entries
} else {
echo "\t...file upload was a SUCCESS\n";
echo "\t...deleting test file\n";
@ ftp_delete($FTP, $FTP_TEST_FILE);
echo "\t...logging out\n";
echo "Stopped FTP Server Test\n\n";
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.