I have a problem with ftp via command line.
This is how I run the ftp file:
ftp -i -s:backup.ftp
pause
And this is my ftp file:
open HOST
USER
PASS
mget *.json
disconnect
quit
I am getting an error: no such file or directory. However if I change the * by a specific filename, it will work. As you can see, I didn't turn globbing off.
Also, when I connect to another ftp server, globbing does work. It seems like this ftp server blocks globbing or something. Anyone an idea??
Related
I'm trying to download a file from an FTP using a script:
Script.bat
ftp -s:DownloadFiles.ftp
DownloadFiles.ftp
open ftp_server
user
pass
ascii
prompt
lcd D:\LocalPath
mget "File.*.TXT_T;1"
When I run the Script.bat I get the following error:
550-Failed to open CV0:[user]File^^^.20171104_024043.TXT_T; for input
. 550 file not found
According to this link, the problem seems to be that the file name contains multiple dots and the mget command will not found the file. Updating the server might solve the problem but I can't do that.
Has anyone dealt with this before?
I want to use a Batch file to upload files from a folder on my computer.
When I call the FTP Script to do the upload:
FTP -v -i -s:ftp.txt
or
FTP -v -i -s:c:\path\to\file\ftp.txt
Neither of those works, and instead
Error opening script file: ftp.txt
is returned.
Strange thing is, that the exact same script is being executed without problems on another computer.
Opening the batch file with admin-rights does not help. I'm running Windows 10.
Edit: The ftp.txt looks like this:
open ##host##
##user##
##password##
lcd c:\local\path\
cd path/on/server/
binary
mput "*.xxx"
disconnect
bye
Make a new, empty file with echo >ftp.test and try with that file.
If that gives you the same error, you'll need to look at your execution environment (look at set and the process owner of cmd.exe). It's also possible that the ftp command is being run as a user that doesn't have access to that file.
If you don't get an error then it's probably either a file-permissions or special-character issue with ftp.txt. Retyping the same content into a different file will get around those issues. Remember not to copy/paste because you could accidentally copy invisible special characters that you're trying to avoid.
I would like to add to this conversation since there have been a lot of views and no solution. I had the same response and it wasn't a permissions issue. It was also no the text file that was the issue because it never technically reached the text file. It was the path to the text file. The following for me didn't work. I had to put quotations around the path even though there were no spaces to confuse the command line.
What you tried:
FTP -v -i -s:c:\path\to\file\ftp.txt
What I tried and worked. (I didn't need to use -v, mine works without it)
FTP -i -s:"c:\path\to\file\ftp.txt"
Running the file acted normal for me. My issue was trying to run the batch file through Windows Task Manager. Somehow, this was causing it to lose the text file somehow. I hope this helps anyone else who reads this thread.
I had to put the .txt file path in the "Start In" section for it to work in Windows Task Manager. No problems since.
I try to copy a lot o file from my ftp = ftp://ftp.prodega.ch so:
I created a code.txt file with this text:
open ftp://ftp.prodega.ch
user
password
lcd /D "E:\f2\" //this is my local directory
cd Bilder1/ //this is ftp folder
mget *
pause
the I execute in cmd this row : ftp -s:code.txt but I meet with this error:
unknown host: ftp://ftp.prodega.ch
help me please
When connecting to a server via the built-in FTP client you have to skip ftp://!
So open ftp.prodega.ch will fix your issue.
However, you might still face another problem. The standard FTP client doesn't support passive mode which is required by most of the servers. If you are not able to modify the server, you won't be able to download the files. You should consider using a PowerShell script instead or use a different FTP client with command line support.
The command I am sending is:
ftp -s:ftp.txt
Here are the contents
open host.com
user
pass
lcd .
cd ./public_html/path/to/dumps
binary
mput "omega.txt2"
mput "wo.txt2"
When I run this, it logs in just fine but then stops. How can I make it run the mput commands also once it connects?
ftp displays a confirmation prompt to start uploading and waits for your input.
Use -i command line switch to disable prompting:
ftp -i -s:ftp.txt
Try to debug your script by connecting without it and then run each ftp command by typing in cmd:
ftp ftp.host.com
user
...
mput "wo.txt2"
This might help:
Ftp
Ftp subcommands
There is a ftp command in my batch script :
FTP -n -s:D:\scripts\Test\get.ftp
Where get.ftp contains all ftp commands including "mget abc*".
Issue here is when file(s) of names starting with abc* is not available, mget is not failing. Also, if any other ftp command fails also, the script is not exiting with error status 1. i.e. "FTP -n -s:D:\scripts\Test\get.ftp" exiting without issues.
Not able to make the batch script fail when there is no file to pick up.
Need suggestion if someone has faced similar issue.
-Krishna
The mget command works by obtaining a remote folder listing and parsing the list for the wildcard pattern that you provide. As long as the listing can be obtained successfully,
it is not considered an error if your pattern did not match any of the files on the list.
Your batch script can be setup to compare the local folder listing before and after invoking the ftp command to check if a file was downloaded. You can also use a scripted ftp solution like kermit or ftp script to be able to have more control on error reporting.