/usr/local/bin/php <? $ftp_server = getenv("ftp_ip"); $ftp_user_name = getenv("ftp_username"); $ftp_user_pass = getenv("ftp_password"); $ftp_remote_path = getenv("ftp_path"); $ftp_remote_file = getenv("ftp_remote_file"); $ftp_local_file = getenv("ftp_local_file"); $conn_id = ftp_connect($ftp_server); if (!$conn_id) { echo "Unable to connect to $ftp_server\n"; exit(1); } $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if (!$login_result) { echo "Inavalid login/password for $ftp_user_name on $ftp_server"; exit(2); } if (!ftp_chdir($conn_id, $ftp_remote_path)) { echo "Invalid remote path '$ftp_remote_path'"; exit(3); } if (ftp_get($conn_id, $ftp_local_file, $ftp_remote_file, FTP_BINARY)) { exit(0); } else { echo "Error while downloading $ftp_remote_file"; exit(4); } ?>