How to run batch file after file download (from Linux to Windows) throught FTP in Windows - windows

I am doing file copy from Linux to Windows share through FTP.
Once copy is done I am moving it to isilon storage which is shared on network path (manually).
Now I have created a batch file, which will do copy from FTP shared path to network path.
So how can I start batch file after FTP download? How can I automate it completely?
from Linux
ftp -n ip
user "user" "pwd"
put app.tar.gz
Once it is done i want to move it network shared path

Just use the copy command in a batch file, after the ftp.exe finishes:
ftp.exe -s:download.txt
copy c:\dowloadtarget\myfile.txt \\server\share\target\myfile.txt
You can run the copy even from the FTP script (the download.txt), if you need it for some reason. Use the ! (escape to shell) command.
get /remote/path/myfile.txt c:\dowloadtarget\myfile.txt
! copy c:\dowloadtarget\myfile.txt \\server\share\target\myfile.txt
But why don't you download the file directly to the shared folder?
get /remote/path/myfile.txt \\server\share\target\myfile.txt

Related

Upload files to SFTP server and delete or archive the source files afterwards

I can't figure out a way to automatically sync files with an SFTP server that will do the following.
Syncs files from local PC to the SFTP
After upload deletes the file on the local PC and keeps SFTP file or
After upload moves the file that has been uploaded to another file for review.
I've tried using Ftpbox but it doesn't have the options.
WinSCP but couldn't find a script that would work.
Remote-Sync but didn't have the options.
If just want to move local files to a remote folder, use the WinSCP put command with the -delete switch.
A full Windows batch file would be like:
winscp.net /log=upload.log /command ^
"open sftp://username:password#example.com/ -hostkey=""ssh-rsa 2048 xxxxxxxxxxx...=""" ^
"put -delete C:\local\path\* /remote/path/" ^
"exit"
Have WinSCP generate the open command or even a complete batch file for you.
If you want to move/archive the local files to another local folder after the upload, it is more complicated.
See the official WinSCP example Moving local files to different location after successful upload.

How to write command in windows batch file to copy a zip file from an FTP path to a local folder in my computer

I want to copy a zip file from an FTP path to a local folder in my computer.
My client previously used coreftp.exe for that purpose. But now he ask us to use ftp.exe [default in windows machine, available at C:\Windows\System32\ftp.exe] for that purpose. The ftp is in the format :
ftp://username#ftpserver.address.com
And want to download it to d:\sample\docs folder on my machine.
I want that in a batch file so that I can schedule it through windows task manager.
So could you please help me to write that command on the batch file.
Thanks a lot in advance.
FTP.EXE is capable of executing script files. So you could just put this into your bat file:
#ECHO OFF
CD d:\sample\docs
FTP -v -i -s:C:\some\path\ftpscript.txt
And something like this into your ftpscript.txt:
open ftp://ftpserver.address.com
username
password
cd myfolder
get some_zip_file.zip
disconnect
bye
This will download some_zip_file.zip into the current directory (d:\sample\docs).

In FTP, how do I copy a remote file to other directories

Using FTP commands I want to upload a large file once and then copy that file to many directories on the remote FTP server. All the copy commands seems to relate to copying from local to remote or the other way around.
Is there an FTP command to copy remote to remote?
are you trying to move the file? if yes, you can do it using rename command to move the file, as for copy i guess you still have to do the the get,send from local-remote way.
as for move command should be something like this
rename /oldpath/file2move.txt /newpath/file2move.txt
Basically just rename your file path that is infront of the file that you wish to move.
As far as I know, there is no such command available in FTP protocol. There are some extensions to SFTP protocol to do this (and, having SSH access, you can issue cp commands), but SFTP is not an FTP.

Is it possible to copy files through ftp connection?

I use the following code to put a file from my local machine to a remote machine:
open abc
a
b
lcd C:\Interfaces\KGR-ARV\XML
ascii
prompt
prompt
cd /usr/qkreditnethome/interface/temp
put C:\Interfaces\KGR-ARV\XML\*KGRRequest*QUA.XML
Y
quit
bye
Is there a way, using a ftp command, to copy the file from /usr/qkreditnethome/interface/temp to /usr/qkreditnethome/interface/temp2 ?
Thanks in advance!
There is no copy command in ftp. You will have to GET the file and PUT it where you want.
Depending on the OS you can take some third-party software which mounts the remote FTP as a part of the local filesystem, and then use regular system copy routines.

FTP Batch file moving remote files

I have an FTP batch file that uses DOS commands to pull down some files. After I'm done pulling the files down, I would like to move the files to an archive directory on the remote server. What FTP DOS commands do I use to accomplish this?
*I wasn't clear at first but this move has to take place on the remote server.
before you pull the files down, you can use the lcd (local cd) command to move to your archive directory and then pull them down directly there. you can then lcd back to your working directory.
otherwise you can perform the move in your bat after your ftp session is completed.
edit:
in the case that your archive server is remote, your best bet is to finish your ftp session and then perform the move in your .bat.
ftp has a rename command, that should move files remotely. I haven't tried it though

Resources