Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
02-24-2009, 12:47 PM
|
#1
|
LQ Newbie
Registered: Nov 2006
Posts: 6
Rep:
|
FTP automation question..
I dont know if this is the thread to put this question to.. if not please move, i could'nt find a scripting thread!!
Q> i am automating an ftp session like this
a file ftp_auth
>> cat ftp_auth
open ftp.sunfreeware.com
user anonymous anonymous
and initiating connection
>> ftp -inv < ftp_auth
Now there isnt any problem with connection and all that... but the connection terminates without waiting for prompt.
Here's the output
>> ftp -invd < ftp_auth
Connected to sunfreeware.com.
220 ftp.sunfreeware.com FTP server ready.
---> SYST
530 Please login with USER and PASS.
---> USER anonymous
331 Guest login ok, send your complete e-mail address as password.
---> PASS XXXX
230-
230-==============================================
230-This is the ftp.sunfreeware.com ftp server
230-
230-If you have not already done so, make sure
230-you have read the Downloading/Installation,
230-FAQ, and Disclaimer links on
230-http://sunfreeware.com.
230-
230-This is a restricted access system. All
230-transfers are logged. If you disagree
230-with this practice, log off now.
230-
230-Questions go to Steve Christensen at
230-the address given on sunfreeware.com.
230-==============================================
230-
230-
230 Guest login ok, access restrictions apply.
---> QUIT
221-You have transferred 0 bytes in 0 files.
221-Total traffic for this session was 803 bytes in 0 transfers.
221-Thank you for using the FTP service on ftp.sunfreeware.com.
221 Goodbye.
Now if i do the same thing.. but without using the file ftp_auth, putting in each line manually the ftp connection is not terminated.
Can someone better make me understand where is the QUIT command is coming from ?
.... waiting for reply asap ....
|
|
|
02-24-2009, 01:28 PM
|
#2
|
LQ Newbie
Registered: Aug 2003
Posts: 7
Rep:
|
.netrc is your friend
Hi mikidouglas, try this:
Create a file in the directory you'll be running the ftp session in named ".netrc". The .netrc file should look something like:
~~~~~~~~~~~~~~~~~~ clip ~~~~~~~~~~~~~~~~~~~~~~
machine ftp.sunfreeware.com
login anonymous
password anonymous
macdef init
cd pub/freeware
dir
bin
~~~~~~~~~~~~~~~~~~ clip ~~~~~~~~~~~~~~~~~~~~~~
The blank line at the end of the macro is mandatory.
Make .netrc private:
prompt> chmod 600 .netrc
Then just:
prompt> ftp ftp.sunfreeware.com
You'll see that all the ftp commands after "macdef init" are executed. Add any you want. Just be sure to have a blank line at the end. You may need certain ftp options (like -p) on some sites.
prompt> man netrc
for more details, but note; contrary to man page, in my experience, the .netrc does NOT have to be in your $HOME directory. This allows you to have many .netrc's in different directories to do different things. Very handy, powerful, & flexible.
|
|
|
02-24-2009, 01:32 PM
|
#3
|
LQ Newbie
Registered: Aug 2003
Posts: 7
Rep:
|
P.S.
I think the "QUIT" comes from the EOF (end of file) on your redirected input. Same as doing <ctrl-d>.
|
|
|
02-24-2009, 05:58 PM
|
#4
|
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,196
|
Dunno what exactly your intention is, and if you need to up/download a specific file or that you want to see directory listings etc.
Both wget and ncftpget are able to download from FTP sites in batch, ncftpput can upload files.
I hope this is useful information.
jlinkels
|
|
|
02-25-2009, 08:56 AM
|
#5
|
ELF Statifier author
Registered: Oct 2007
Posts: 676
Rep:
|
Quote:
Originally Posted by mikidouglas
>> cat ftp_auth
open ftp.sunfreeware.com
user anonymous anonymous
|
You only ask to connect to the ftp site and log in.
If you add some commands (say 'get /some/file')
after 'user anonymous anonymous' ftp will (should) execute them
By the way for the tasks like this I usually use script:
Code:
#!/bin/sh
ftp <ip_address> -ivn << FTP_COMMANDS
open ....
user ...
other ftp commands
FTP_COMMANDS
|
|
|
All times are GMT -5. The time now is 09:06 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|