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 Dec 8, 2014 | 01:02 PM
  #1  
urban's Avatar
urban
Thread Starter
Scooby Regular
iTrader: (1)
 
Joined: Mar 2002
Posts: 12,566
Likes: 1
From: Never you mind
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.
Reply
Old Dec 8, 2014 | 03:16 PM
  #2  
bioforger's Avatar
bioforger
Scooby Regular
iTrader: (1)
 
Joined: Jan 2002
Posts: 16,995
Likes: 5
From: Pig Hill, Wiltsh1te
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
Reply
Old Dec 9, 2014 | 08:29 AM
  #3  
urban's Avatar
urban
Thread Starter
Scooby Regular
iTrader: (1)
 
Joined: Mar 2002
Posts: 12,566
Likes: 1
From: Never you mind
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.
Reply
Old Dec 9, 2014 | 10:54 AM
  #4  
bioforger's Avatar
bioforger
Scooby Regular
iTrader: (1)
 
Joined: Jan 2002
Posts: 16,995
Likes: 5
From: Pig Hill, Wiltsh1te
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.
Reply
Old Dec 9, 2014 | 01:12 PM
  #5  
urban's Avatar
urban
Thread Starter
Scooby Regular
iTrader: (1)
 
Joined: Mar 2002
Posts: 12,566
Likes: 1
From: Never you mind
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.
Reply
Old Dec 9, 2014 | 03:02 PM
  #6  
bioforger's Avatar
bioforger
Scooby Regular
iTrader: (1)
 
Joined: Jan 2002
Posts: 16,995
Likes: 5
From: Pig Hill, Wiltsh1te
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.
Reply
Old Dec 9, 2014 | 04:18 PM
  #7  
urban's Avatar
urban
Thread Starter
Scooby Regular
iTrader: (1)
 
Joined: Mar 2002
Posts: 12,566
Likes: 1
From: Never you mind
Default

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

Yea its much better, language wise its similar to c++
Reply
Old Dec 9, 2014 | 10:27 PM
  #9  
tarmac terror's Avatar
tarmac terror
Scooby Regular
iTrader: (2)
 
Joined: May 2005
Posts: 2,500
Likes: 0
From: Northern Ireland
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
Reply
Old Dec 10, 2014 | 08:12 AM
  #10  
urban's Avatar
urban
Thread Starter
Scooby Regular
iTrader: (1)
 
Joined: Mar 2002
Posts: 12,566
Likes: 1
From: Never you mind
Default

Genius - Cheers
Reply
Old Dec 11, 2014 | 01:10 AM
  #11  
bioforger's Avatar
bioforger
Scooby Regular
iTrader: (1)
 
Joined: Jan 2002
Posts: 16,995
Likes: 5
From: Pig Hill, Wiltsh1te
Default

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




All times are GMT +1. The time now is 08:48 AM.