Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Windows batch file

Thread Tools
 
Search this Thread
 
Old 08 December 2014, 01:02 PM
  #1  
urban
Scooby Regular
Thread Starter
iTrader: (1)
 
urban's Avatar
 
Join Date: Mar 2002
Location: Never you mind
Posts: 12,566
Received 1 Like on 1 Post
Default 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.
Old 08 December 2014, 03:16 PM
  #2  
bioforger
Scooby Regular
iTrader: (1)
 
bioforger's Avatar
 
Join Date: Jan 2002
Location: Pig Hill, Wiltsh1te
Posts: 16,995
Received 5 Likes on 5 Posts
Default

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
Old 09 December 2014, 08:29 AM
  #3  
urban
Scooby Regular
Thread Starter
iTrader: (1)
 
urban's Avatar
 
Join Date: Mar 2002
Location: Never you mind
Posts: 12,566
Received 1 Like on 1 Post
Default

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.
Old 09 December 2014, 10:54 AM
  #4  
bioforger
Scooby Regular
iTrader: (1)
 
bioforger's Avatar
 
Join Date: Jan 2002
Location: Pig Hill, Wiltsh1te
Posts: 16,995
Received 5 Likes on 5 Posts
Default

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.
Old 09 December 2014, 01:12 PM
  #5  
urban
Scooby Regular
Thread Starter
iTrader: (1)
 
urban's Avatar
 
Join Date: Mar 2002
Location: Never you mind
Posts: 12,566
Received 1 Like on 1 Post
Default

Cheers.

Problem I have is that we're not allowed access to the unix server, so we're doing the reverse and using mget.
Old 09 December 2014, 03:02 PM
  #6  
bioforger
Scooby Regular
iTrader: (1)
 
bioforger's Avatar
 
Join Date: Jan 2002
Location: Pig Hill, Wiltsh1te
Posts: 16,995
Received 5 Likes on 5 Posts
Default

Yep i know where you're coming from, same issues here, i had to fight tooth n nail just to be able to use a FTP client! everything is locked down to the max, stupid regulations and security

Anwyay thats another reason for using powershell or similar.
Old 09 December 2014, 04:18 PM
  #7  
urban
Scooby Regular
Thread Starter
iTrader: (1)
 
urban's Avatar
 
Join Date: Mar 2002
Location: Never you mind
Posts: 12,566
Received 1 Like on 1 Post
Default

Currently looking at powershell, haven't really done much with it before.
But it looks a lot more robust than the batch script.
Old 09 December 2014, 07:25 PM
  #8  
bioforger
Scooby Regular
iTrader: (1)
 
bioforger's Avatar
 
Join Date: Jan 2002
Location: Pig Hill, Wiltsh1te
Posts: 16,995
Received 5 Likes on 5 Posts
Default

Yea its much better, language wise its similar to c++
Old 09 December 2014, 10:27 PM
  #9  
tarmac terror
Scooby Regular
iTrader: (2)
 
tarmac terror's Avatar
 
Join Date: May 2005
Location: Northern Ireland
Posts: 2,498
Received 0 Likes on 0 Posts
Default

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
Old 10 December 2014, 08:12 AM
  #10  
urban
Scooby Regular
Thread Starter
iTrader: (1)
 
urban's Avatar
 
Join Date: Mar 2002
Location: Never you mind
Posts: 12,566
Received 1 Like on 1 Post
Default

Genius - Cheers
Old 11 December 2014, 01:10 AM
  #11  
bioforger
Scooby Regular
iTrader: (1)
 
bioforger's Avatar
 
Join Date: Jan 2002
Location: Pig Hill, Wiltsh1te
Posts: 16,995
Received 5 Likes on 5 Posts
Default

lol that's what i use
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
KAS35RSTI
Subaru
27
04 November 2021 07:12 PM
FuZzBoM
Wheels, Tyres & Brakes
16
04 October 2015 09:49 PM
Ganz1983
Subaru
5
02 October 2015 09:22 AM
Nick_Cat
Computer & Technology Related
2
26 September 2015 08:00 AM
Littleted
Computer & Technology Related
0
25 September 2015 08:44 AM



Quick Reply: Windows batch file



All times are GMT +1. The time now is 03:27 AM.