Windows batch file
#1
Windows batch file
Guys
Any of you any good with this?
Here's what i'm after.
A batch scripts which FTP's files from another machine, stores them in a location locally, but goes back to the FTP machine and deletes the local copy on there so it doesn't get transferred again.
Any of you any good with this?
Here's what i'm after.
A batch scripts which FTP's files from another machine, stores them in a location locally, but goes back to the FTP machine and deletes the local copy on there so it doesn't get transferred again.
#2
Scooby Regular
iTrader: (1)
Simplify it first, from the FTP machine, move the file(s) to the other machine, that will take care of the "deletion" of the file(s) on the FTP machine.
Then you can do the script from the FTP machine only. Have a look here;
http://www.dostips.com/DtTipsFtpBatchScript.php
I would use this command;
FTP -v -i -s:ftpscript.txt
Then you can call the FTP commands from the ftpscript.txt file;
open example.com
username
password
!:--- FTP commands below here ---
lcd c:\MyLocalDirectory
cd public_html/MyRemoteDirectory
binary
mput "filename*.*"
delete "filename*.*"
disconnect
bye
Then you can do the script from the FTP machine only. Have a look here;
http://www.dostips.com/DtTipsFtpBatchScript.php
I would use this command;
FTP -v -i -s:ftpscript.txt
Then you can call the FTP commands from the ftpscript.txt file;
open example.com
username
password
!:--- FTP commands below here ---
lcd c:\MyLocalDirectory
cd public_html/MyRemoteDirectory
binary
mput "filename*.*"
delete "filename*.*"
disconnect
bye
#3
Thanks for the post.
Problem with your script is that its got the potential to delete more than its transfers which is where I'm having issues.
Also moving the files - we're basically taking about getting files from an old unix server to a windows machine.
Problem with your script is that its got the potential to delete more than its transfers which is where I'm having issues.
Also moving the files - we're basically taking about getting files from an old unix server to a windows machine.
#4
Scooby Regular
iTrader: (1)
You mean in the case of a file transfer or FTP failure ?
So if the FTP MPUT command is successful then build a filelist of those files to delete from local. Building the filelist i know how to do, but i dont know how you would determine if MPUT has succeeded or not in a DOS batch, as Dos FTP.exe does not return any error codes!
I guess you could build in error level checking and log the errors, but then it gets a bit tricky
To be honest something like this is better off using powershell or python rather than dos batches as these have access to an FTP client and can be dynamically controlled. You'll know exactly whats worked or failed and be able to deal with any issues.
So if the FTP MPUT command is successful then build a filelist of those files to delete from local. Building the filelist i know how to do, but i dont know how you would determine if MPUT has succeeded or not in a DOS batch, as Dos FTP.exe does not return any error codes!
I guess you could build in error level checking and log the errors, but then it gets a bit tricky
To be honest something like this is better off using powershell or python rather than dos batches as these have access to an FTP client and can be dynamically controlled. You'll know exactly whats worked or failed and be able to deal with any issues.
Trending Topics
#9
Scooby Regular
iTrader: (2)
If you are having a crack at this in powershell - this may make things a bit easier for you.
https://gallery.technet.microsoft.co...lient-db6fe0cb
https://gallery.technet.microsoft.co...lient-db6fe0cb
Thread
Thread Starter
Forum
Replies
Last Post