Introduction

It’s sometimes convenient to automate certain tasks like uploading files or other operations.

FTP

With the universal ftp command, here’s an example that you can place in a shell script:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
transfertFile()
{
   inputFile=$1
 
   ftp -n <<end
      prompt
      open $Hostname $Port
      user $Login $Password
      ascii
      put $inputFile
      bye
end
}

NCFTP

With the ncftp utility, it’s even simpler since it works with just one line:

1
ncftpput -u $LOGIN -p $PASSWORD $ADDRESS DESTINATION-DIRECTORY FILE-TO-UPLOAD

Last updated 22 Jul 2008, 07:30 CEST. history