I'm on windows 8.1 and using ftp from the cmd console (run as administrator).
If I enter:
ftp -v -i -A thispc
Note: "thispc" is mapped in the hosts file to my local ip address
If I then enter:
mput *.*
all the files in my current folder get pushed to my ftp server.
However, if I try to do this from a .bat file, it does not work.
The .bat file:
#echo off
ftp -v -i -A thispc -s:send_file.txt
The contents of send_file.txt:
mput *.*
quit
I get the ftp help text instead when I run it via this .bat file with the following note:
mget and mput commands take y/n/q for yes/no/quit
The -i in the ftp call is supposed to disable that.
Does anyone know how I can get this to work.
OK - figured it out.
Quite simply:
ftp -v -i -A -s:send_file.bat thispc
instead of:
ftp -v -i -A thispc -s:send_file.txt
The error messages from ftp are not very useful :-)
Try
prompt
mput *.*
quit
In you input file.
Related
Ive been using a .bat script to download only pdfs from an FTP server.
Up until now its been working perfectly using the mget *pdf function.
I recently moved the script and have it running from a Windows 2012 Server.
And now when script gets to the mget function, it lists the files that would normally transfer except with a ? after each instance, it then fails to actually download them to the lcd.
#ftp -v -n -i -s:C:\Users\LMCT\Desktop\Serversidesage\download-1.txt
This is the FTP function being called.
open xx.xxx.xx.xxx
user xxxxxxxxxxx
=xxxxxxxxxxxx
cd orders
lcd "C:\Users\LMCT\Desktop\Magento-downloaded-orders"
binary
prompt
mget *pdf
mdelete *pdf
quit
And this is the downloading script.
Does anyone know why this might be happening?
Thanks in advance.
Kind Regards, Lewis.
By Default Interactive Prompting is ON. When you used the -I option to launch the FTP command it is turning Prompting off. In your script you are then turning it back on with the PROMPT command which then throws off your MGET command.
So if the PROMPT command is in your FTP script:
open ftp.domain.com
user ftpuser
password
prompt
quit
It is easy test to see what is going on.
C:\BatchFiles\ftp>ftp -v -i -n -s:"script.txt" |find "Interactive"
Interactive mode On .
C:\BatchFiles\ftp>ftp -v -n -s:"script.txt" |find "Interactive"
Interactive mode Off .
I want download a bunch of .txt.gz files by ftp. I've written this shell script. How do I get all the files on the sever with out specifying each file?
Some code..
#!/bin/bash
ftp -i -n <<Here
open ftplink.com
user Username password
bin
get XXX_xxxx_mp.txt.gz
get XXX_xxxx_mp.txt.gz
close
quit
Here
Use wget instead:
wget ftp://user:pass#example.com/dir/*_mp.txt.gz
I am using ftp in the command line (terminal) to transfer multiple data files from a remote server to my local computer. There are multiple files (~40) in the directory and I would like to transfer them all without having to answer yes in the prompt for each file. I tried mget * but this only transferred the first file and then a prompt popped up for the second file.
Issue a prompt command first to turn interactive prompting off.
Alternatively, if you have control over the way the ftp command is called, use the command line option, as suggested by #reg-edit:
ftp [-i | --no-prompt] [OPTIONS] [HOST [PORT]]
As an alternative to issuing a prompt command ahead of your other commands, you may invoke ftp with the -i switch.
When you already started ftp you can issue the prompt command to toggle between getting prompted and not getting prompted. So this should do the trick:
> ftp <some server>
ftp> prompt
Interactive mode OFF .
ftp> mget *
I want to ftp file to my remote server and then move those files into another directory in the remote server
The ftp happens correctly but the movement is throwing an error like
550 RNFR command failed.
Can you please help?
My script is
#!/bin/sh
echo "Enter the version of the xml (eg:- v17.25)"
read version
HOST_FIRST='un01'
HOST_LAST='01'
USER='someuser'
PASSWD='somepassword'
HOST="$HOST_FIRST$FILE$HOST_LAST"
ftp -n $HOST <<-END_SCRIPT
quote USER $USER
quote PASS $PASSWD
cd /tmp
put myfile.xml
rename myfile.xml /tmp/test_ftp
quit
END_SCRIPT
exit 0
You have put myfile.xml to the tmp dir, why not just
edit
Change your script from
rename myfile.xml /tmp/test_ftp
TO
rename myfile.xml test_ftp
You have already put the file in the /tmp directory, which you have already done a cd /tmp .
That should work.
You can't specify a path in an ftp rename command and expect it to be moved as well.
And sorry, not what you want to here, but there is no move command in ftp. It is that way for security.
IHTH.
Hi I have created a ftp cmd script that would copy the text files from local source to ftp folder destination. copying was succesful. but i want it to be more complex that after successfull copying, copy to another local folder (will serve as backup copy of text files, increment file name by 1 when exists) then it would delete the copied text files from the source.
My script goes like:
#ftp -i -s:"%~f0"&GOTO:EOF
open [172.16.xx.xx]
oracle
mypassword
cd /ftp_destination/
mput D:/local_source_folder
quit
I know it is to much to ask and it is a bit complex, but helping a newbie would be a great help. Thanks for advance help.
#ftp -i -s:"%~f0"&GOTO:EOF
open [172.16.xx.xx]
oracle
mypassword
cd /ftp_destination/
mput D:/local_source_folder
!del /q D:/local_source_folder
quit
! is the shell command for FTP, and anything after it will be executed in a "dos" shell.
Alternitively, you can just do !ENTER and FTP will open a "dos" shell for you to type in. EXIT will return you to ftp. Like this:
#ftp -i -s:"%~f0"&GOTO:EOF
open [172.16.xx.xx]
oracle
mypassword
cd /ftp_destination/
mput D:/local_source_folder
!
del /q D:/local_source_folder
exit
quit