Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-5 of 5 total  RSS 

FTPS upload a file from Ruby using Curl command line

Yes, this is lame, but I didn't have much luck with Ruby libraries, so this is what I came up with.

`curl -k --ftp-ssl -3 -T#{path} -u#{FTP_USER}:#{FTP_PASS} #{FTP_HOST}`


-k forces the connection even if the cert looks bad
-3 turns on SSLv3
-T file to upload
-u user:password

FTP to get a file from within PHP

$conn_id = ftp_connect("www.yoursite.com");
$login_result = ftp_login($conn_id, "username", "password");

if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
exit;
} else {
echo "Connected";
}

// get the file
$local = fopen("local.txt","w");
$result = ftp_fget($conn_id, $local,"httpdocs/trlog.txt", FTP_BINARY);

// check upload status
if (!$result) {
echo "FTP download has failed!";
} else {
echo "Downloaded ";
}

// close the FTP stream
ftp_close($conn_id);

ftp recipes

Recursively Transfer all files in certain directory
ncftpget -u <username> -p <password> -R ftp://ftp.microsoft.com/Files/

Mouting Directories for vsftp

mount --rbind /mnt/pub /home/pub

* logs are located at /var/log/vsftpd.log and /var/log/xferlog

Send a file using FTP

import ftplib
s = ftplib.FTP('myserver.com','login','password') # Connect

f = open('todo.txt','rb')                # file to send
s.storbinary('STOR todo.txt', f)         # Send the file

f.close()                                # Close file and FTP
s.quit()

Taken (with some mod.) from here
« Newer Snippets
Older Snippets »
Showing 1-5 of 5 total  RSS