We have moved to www.dataGenX.net, Keep Learning with us.

Monday, February 25, 2013

FTP auto-login Script



FTP auto-login.  "ftp" to a site and have the password stored.

For instance, here's a sample ".net" file in a user's home directory for uploading to sourceforge. Note, sourceforge will take any password, so m@temp.com is used here for login "anonymous".





#!/bin/bash
#
#  Sample ftp automated script to download
#  file to ${dwnld}
#
dwnld="/work/faq/unix-faq"
cd ${dwnld}
ftp << FTPSTRING
prompt off
open rtfm.mit.edu
cd /pub/usenet-by-group/news.answers/unix-faq/faq
mget contents
mget diff
mget part*
bye
FTPSTRING


Sourceforge uses an anonymous login with an email address as a password. Below is the automated script I use for uploading binary files.



#!/bin/bash
# ftp sourceforge auto upload ftpup.sh
#   Usage: ./ftpup.sh <filename>
#
# machine upload.sourceforge.net user anonymous m@aol.com
ftp -n -u <<  FTPSTRING
open upload.sourceforge.net
user anonymous m@aol.com
binary
cd incoming
put ${1}
bye
FTPSTRING