Tag Archive for FTP

ACCESS FTP Upload

Function FTP_Data()
'=========================================================================
'FTP from Microsoft Access
'by Matthew V Carmichael
'Craetes FTP Batch File, FTP command file (txt)
'Default directory location of files to upload/download is
'the same location as the mdb file that contains this module.
'========================================================================='
On Error GoTo Err_Trap

Dim pFile As Long
Dim strPath As String
Dim strFileName As String
Dim ftpServer As String
Dim strUserName As String
Dim strPassword As String

'Path and Name of file to FTP
strPath = CurrentProject.Path & ""
strFileName = "Test.mdb" 'Name of file to upload
'FTP Server Settings
ftpServer = "Your FTP Server"
strUserName = "Your FTP User Name"
strPassword = "Your FTP Password"

'Create text file containing FTP commands
pFile = FreeFile
Open strPath & "FTP_cmd.txt" For Output As pFile
Print #pFile, "user"
Print #pFile, strUserName
Print #pFile, strPassword
Print #pFile, "Put " & strFileName
'Use the Put command to upload, use the Get command to download.
'Print #pFile, "Get " & "Your File Name"
Print #pFile, "quit"
Close pFile

'Create batch file to execute FTP
pFile = FreeFile
Open strPath & "FTP_Run.bat" For Output As pFile
Print #pFile, "ftp -n -s:" & "FTP_cmd.txt " & ftpServer
Print #pFile, "Pause"
Close pFile

'Execute FTP command
Shell strPath & "FTP_Run.bat", 1

Err_Trap_Exit:
Exit Function

Err_Trap:
MsgBox Err.Number & " - " & Err.Description
Resume Err_Trap_Exit

End Function

source

tar basics

# create
tar cvf docs.tar docs2

# extract
tar xvf docs.tar

source

cURL in PHP

/**
* cURL file copy to another server
* This file saved my life when i had to let a file upload synchrom to a different server, no ftp messing around!
*/
$rCurl = curl_init();

/**
* The file to copy
*/
curl_setopt($rCurl, CURLOPT_URL, 'http://www.google.nl/intl/nl_nl/images/logo.gif');

/**
* cURL options dunno what for
*/
curl_setopt($rCurl, CURLOPT_HEADER, false);

/**
* cURL options dunno what for
*/
curl_setopt($rCurl, CURLOPT_BINARYTRANSFER, true);

/**
* cURL options dunno what for
*/
curl_setopt($rCurl, CURLOPT_RETURNTRANSFER, true);

/**
* The php file limit
*/
set_time_limit(300);

/**
* set cURL timeout
*/
curl_setopt($rCurl, CURLOPT_TIMEOUT, 300);

/**
* The file that will be written
*/
$rOutPut = fopen('googlelogo.gif', 'wb');

/**
* Setup the transfer ?
*/
curl_setopt($rCurl, CURLOPT_FILE, $outfile);

/**
* Execute the transfer
*/
curl_exec($rCurl);

/**
* Close the file
*/
fclose($rOutPut);

/**
* Close cURL
*/
curl_close($rCurl);

source

FTP Uploader

# Import FTP library:
import ftplib
# Connect to the server:
s = ftplib.FTP('server','user','password')
# Open file to send:
f = open('/folder/folder/local_filename','rb')
# Store file on server:
s.storbinary('STOR server_filename', f)
# Close sent file:
f.close()
# Close server connection:
s.quit()

source

Net::FTP to ftp a file

use Carp;
use Net::FTP;

my $ip  = ...; # Target machine

my $local= ...; # local filename
croak "$local file is missing !!
" unless -f $local;

my $remote= ...; # Remote filename

my $ftp= Net::FTP->new( $ip
,Port    => 21  # Standard port number
,Timeout => 15  # Timeout in seconds
)
or croak "Failed to connect to $ip.";

my $user= ...;  # login user
my $pw  = ...;  # login password
$ftp->login( $user, $pw )
or croak "Failed to login.";

$ftp->put( $local, $remote)
or croak "Failed to <a href="http://ftp.";" >ftp.";</a>

$ftp->quit();

source