I want a batch file to ftp to a server, read out a text file, and disconnect. The server requires a user and password. I tried
@echo off
pause
@ftp example.com
username
password
pause
but it never logged on. How can I get this to work?
I want a batch file to ftp to a server, read out a text file, and disconnect. The server requires a user and password. I tried
@echo off
pause
@ftp example.com
username
password
pause
but it never logged on. How can I get this to work?
Here's what I use. In my case, certain ftp servers (pure-ftpd for one) will always prompt for the username even with the -i parameter, and catch the "user username" command as the interactive password. What I do it enter a few NOOP (no operation) commands until the ftp server times out, and then login:
I have written a script as *.sh file
Works fine for me
The answer by 0x90h helped a lot...
I saved this file as u.ftp:
I then ran this command:
And it worked!!!
Thanks a lot man :)
You can use PowerShell as well; this is what I did. As I needed to download a file based on a pattern I dynamically created a command file and then let
ftp
do the rest.I used basic PowerShell commands. I did not need to download any additional components. I first checked if the requisite number of files existed. If they I invoked the FTP the second time with an Mget. I run this from a Windows Server 2008 connecting to a Windows XP remote server.
You need to write the ftp commands in a text file and give it as a parameter for the ftp command like this:
More info here: http://www.nsftools.com/tips/MSFTP.htm
I am not sure though if it would work with username and password prompt.
This is an old post however, one alternative is to use the command options:
the -n will suppress the initial login and then the file contents would be: (replace the 127.0.0.1 with your FTP site url)
This avoids the user/password on separate lines