Creating an automated FTP process on RH Linux

Posted on 2006-04-18
Medium Priority
Last Modified: 2012-05-05
I know this quetion has been asked before, but I cannot find a solution that works.  Here are the essential facts and requirement:

1. I must use FTP.  I know it's not secure, but this is an internal network where security is not an issue.
2. The script must run from RH Linux
3. The connection is to a NAS device that supports FTP
4. The FTP session must be able to be scheduled and run unattended.

I have tried a variety of scripts, but always get "stuck" when FTP requests a password.  For example, I have tried:

ftp < myscript

where myscript is:


just to test out the basic process.  I have also tried variations like USER annymous, but it is always the same - FTP prompts for a password.  This is probably simple, but I'm not getting anywhere.  Could someone please help?  Thanks in advance!

Question by:dkreines
LVL 62

Expert Comment

ID: 16483338
The client you did not find is called ncftp.
First of all install rpm-build package
Then download client from http://www.ncftp.com/ncftp/
Then use rpmbuild against source tarball to make it into rpm package
Then rpm -i ncftp*.rpm
Now use either ncftp tp save profile and anyway ncftpget/put command line to transfer files.

To correct your script - ftp -ni typefile is much better than ftp < typefile

Author Comment

ID: 16488366
Thanks for the response, but it really doesn't address my problem, because I MUST use ftp; loading a different program is not an option.  The real problem is that I cannot get ftp to accept a password from a script.  Maybe this is harder than I thought.

Accepted Solution

bira earned 600 total points
ID: 16489314
try this way

 ftp -n <<endftp
  user youruser yourpassword
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

LVL 51

Expert Comment

ID: 16489323
if you cannot use ncftp or any other ftp which allows what you need, you need to write a script using expect (simple) or perl (more complicated). But if  "loading a different program is not an option" you loose.
LVL 62

Expert Comment

ID: 16491037
> 1. I must use FTP.  I know it's not secure, but this is an internal network where security is not an issue.
> 2. The script must run from RH Linux
> 3. The connection is to a NAS device that supports FTP
> 4. The FTP session must be able to be scheduled and run unattended

Where the hell is that you have to use /usr/bin/ftp from random redhat revision, probably not even enough functional to fetch files from your NAS ???

Sorry - /usr/bin/ftp alone is insufficient to your task.

ncftpget and ncftpput are tools that do what you described to my best understanding - up/download files without user interaction using FTP - file transfer protocol.


Author Comment

ID: 16499308
Thank you, Bira - your solution was perfect.  I had tried various similar forms, but didn't realize that the password went on the same line as the username.  I now have a perfectly functioning scriot (which of course does much more than the trivial sample I used here).  Contrary to the comment by gheist, ftp IS sufficient for this task!  Thanks again.


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question