Creating an automated FTP process on RH Linux

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:

connect 10.10.1.10
anonymous
mypassword
pwd
quit

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!

Dave
dkreinesAsked:
Who is Participating?
 
biraCommented:
try this way

 ftp -n <<endftp
  open 10.10.1.10
  user youruser yourpassword
  pwd
  quit
endftp
0
 
gheistCommented:
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
0
 
dkreinesAuthor Commented:
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.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
ahoffmannCommented:
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.
0
 
gheistCommented:
> 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.


0
 
dkreinesAuthor Commented:
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.

Dave
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.