Simple shell script to FTP file from your Desktop to FTP server

This Tutorial Has Been Viewed 2,644 Times.


#!/bin/sh
HOST='ftp.mistonline.in'
USER=''
PASSWD=''
FILE='file.txt'
ftp -n $HOST << END
quote USER $USER
quote PASS $PASSWDcd databackup/DB/
put $FILE
quit
END
exit 0


The Tricks

Getting the password to the ftp server without having the ftp client program read the password from /dev/tty requires two tricks:

  1. Using the -n option on the ftp client program to prevent the ftp client from trying to log in immediately. That way, the ftp client does not ask for a user ID and password. No use of /dev/tty.
  2. Use the ftp client program command quote to send user ID and password to the ftp server.
  3. The file /dev/tty is a character file with major number 5 and minor number 0, usually of mode 0666 and owner.group root.tty.
  4. /dev/tty helps output displayed to the  (terminal)
VN:F [1.9.13_1145]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 0 votes)

Incoming search terms:

Leave a Reply

Spam protection by WP Captcha-Free

Proudly designed by Mistonline.in.
Affordable Seo PackagesSeo BlogEdu Backlinks
More in shell (2 of 4 articles)