?
Solved

Need to modify ftp script so that it does not move files from que folder to processed folder until actually uploaded

Posted on 2006-05-12
13
Medium Priority
?
285 Views
Last Modified: 2008-02-26
We use an ftp script which uploads files and then moves the files on the local machine from an input folder to a processed folder.  Unfortunately, if the connection is not made or there is a connection error it will still move the files to the processed folder.  I need to modify the script so that the files are not moved from the que folder to the processed folder until they are actually uploaded to the ftp server.  The scripts are shown below.  Thanks

REM this is ftp section
ftp -i -s:c:\script.txt
REM this is copy section
cd c:\ftp\cwcque
xcopy *.* c:\ftp\cwcquedone /E/Q/I
erase c:\ftp\cwcque\*.* /Q
CLOSE

Contents of script.txt
open xxx.xxx.xxx.xxx
USER XXXXX
PASS XXXXXX
cd add
lcd c:\FTP\CWCQue
mput *.*
quit
0
Comment
Question by:gordonrr
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16669217
I don't below this is possible using a batch file in the way you have it setup...

You are calling the ftp utility and telling it to run a script with the -s option:

    ftp -i -s:c:\script.txt

There isn't any way to determine whether that ftp operation was successful or not.

You need a more sophisticated method to perform your operations.  Do you have access to a programming language such as VB6, C#, VB.Net, Delphi....anything?
0
 
LVL 16

Accepted Solution

by:
PaulCaswell earned 672 total points
ID: 16669994
Hi gordonrr,

Try this.

    ftp -i -s:c:\script.txt>script.log
find "error message" script.log
if errorlevel 1 goto NoError

:Error

...

:NoError

...

You need to find an error message in the generated log you can search for in the find and I can never remember wether it returns an errorlevel if it found it or didnt find it so check that on your system.

Paul


Paul
0
 
LVL 1

Assisted Solution

by:rbvoigt
rbvoigt earned 664 total points
ID: 16672700
most flexible way to do this is to use a tool called "expect": http://sourceforge.net/projects/expect
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:rbvoigt
ID: 16672706
Furthermore you should use move and not copy followed by erase.  If the copy fails maybe because lack of disk space....  It will also be instantaneous because it only manipulates the inodes (FAT directories, NTFS indexes), without copying the data.
0
 
LVL 8

Assisted Solution

by:craigwardman
craigwardman earned 664 total points
ID: 16677323
you can try something similar to Paul's idea, but it is more specific..

Basically, before you disconnect from the FTP server, get a directory listing into a local file..

example (in the FTP script after mput):

-----

mls *.* filelist.txt

------

This creates a filelist.txt on your local drive, which you can then process within your batch file as follows:

------

@echo off
@FOR %%f IN (*.*) DO (
find /I "%%f" filelist.txt
if not errorlevel 1 move %%f archive
)

------


That just moves the file into an archive subfolder of the current directory, you can change it as necessary..
0
 

Author Comment

by:gordonrr
ID: 16714023
I do have access to VBA & VB6.
0
 
LVL 1

Expert Comment

by:rbvoigt
ID: 16905854
I don't believe a refund is in order.  He got a complete and correct answer from craigwardman, with some useful advice from others including myself.  I think craigwardman should get 3/4 of the points with 1/8 points to each of PaulCaswell and me.
0
 
LVL 16

Expert Comment

by:PaulCaswell
ID: 16906268
I second than Venabili, including the split balance but I suspect we will get equal points.

Paul
0
 
LVL 20

Expert Comment

by:Venabili
ID: 16906674
Yeah.. correct. :)
Sorry - the VB&VBA last comment confused me for a while...
0
 
LVL 8

Expert Comment

by:craigwardman
ID: 16907205
i concur :)

Thanks for your recognition..
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Simple Linear Regression

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question