Re: File Size Check



On Jan 30, 9:17 am, "Pegasus \(MVP\)" <I....@xxxxxxxxxx> wrote:
"Tom Lavedas" <tglba...@xxxxxxx> wrote in message

news:b9f64c2a-1b5e-4e61-8e27-50d25e141556@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



On Jan 29, 6:24 pm, "Pegasus \(MVP\)" <I....@xxxxxxxxxx> wrote:
"Pete T" <Pe...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message

news:5F353EE6-1A67-427C-B108-9A65A1C04438@xxxxxxxxxxxxxxxx

I have a simple batch file that FTP's out to a server, logs in,
retrieves a
file and places it on my server and then here's where I run into a
problem.

When it was written in XP the batch then checked the size of the file
and
if
it was greater than 0, the batch ended and was done. If the file was
not
greater than 0, it slept for 20 minutes (echo sleep 1200) and then
re-ran
the
FTP process.

Now that this is on Windows 2000, I can't figure out how to make it
work.
Here are the two files that were run:

@echo on
del para2.txt
echo open XXXXXXXXXXXXXX >> para2.txt
echo user XXXXXXXXXXXXXXXXX >> para2.txt
echo binary >> para2.txt
echo hash on >> para2.txt
echo GET XXXXXXXXX >> para2.txt
echo DEL XXXXXXXXX >> para2.txt
echo quit >> para2.txt
progs.bat abc.123.tag

@echo on
del %1
:START
ftp -n -s:para2.txt
if %~z1 GTR 0 goto :END
sleep 1200
goto :START
:END
del para2.txt

Any ideas on how to make this work in Windows 2000?

Since you're not reporting what exactly happens under
Win2000, it's a little hard to say what's wrong. However,
the batch file below will work both under WinXP and under
Win2000. Note that for ease of maintenance it is now one
single file.

@echo off
set FileName=xxxxxxxxx
set Site=ftp.PeteT.com
set User=PeteT

echo> para2.txt open %Site%
echo>> para2.txt user %User%
echo>> para2.txt binary
echo>> para2.txt hash on
echo>> para2.txt GET %FileName%
echo>> para2.txt DEL %FileName%
echo>> para2.txt quit

if exist %FileName% del %FileName%
:START
ftp -n -s:para2.txt
for %%a in (%FileName%) do if %%~za GTR 0 goto END
ping localhost -n 1200 > nul
goto :START
:end
del para2.txt

First, not that I am offended by your choosing to answer, but why is
this in microsoft.public.scripting.vbscript, since this is entirely a
batch command question? I would think alt.msdos.batch.nt would be a
better NG or even microsoft.public.windows.server.scripting or
microsoft.public.win2000.cmdprompt.admin (though this last one has
extremely low activity).

Second, I think you have probably corrected his problem without
explaining why, which I suspect is the missing SLEEP.EXE utility.
Since there is no useful error information it's hard to be sure.
However, SLEEP is part of the WinNT/2K/XP/2003 Resource Kit and not a
standard part of the OS installation, therefore, it is reasonable to
assume the OP's XP system has it installed and his 2K machine does
not.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

As I said, the OP chose not to report any error messages, hence
it was anyone's guess why his script would fail under Win2000.
For all I know he might have had one of the countless "sleep"
utilities on his machine.

However, since the only thing you did different was to substitute the
ping delay for the SLEEP and the OP says it fixed the problem, it
seems to be the issue. While I agree with the combination of the ftp
script into the batch, I don't think that was the problem.

About answering a batch question in a scripting newsgroup:
Your point is well taken and I would normally recommend
that the OP posts his question in the appropriate newsgroup.
Unfortunately there is no MS-sponsored newsgroup for batch
file issues, and I hesitate to recommend the one you mention.
I frequently have a problem with the attitude of some of the
respondents in that group. Perhaps I'm just a little oversensitive.

I apologize if my response seemed like a criticism. It really wasn't
meant in that vein.

Yes there are some snooty participants at the alt.msdos.batch groups
(as there are most everywhere), but there is a greater number of
helpful batch savvy denizens there, I think. I stayed away for a long
time for the very reasons to which you allude. But, all things
considered, they are probably the last real places to get timely batch
help. Besides, you have taken enough grief here over the past weeks
regarding batch solutions.

The other two MS sponsored groups I mentioned are pretty eclectic,
covering batch issues along with scripts and other topics.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
.



Relevant Pages

  • Re: Persisting env vars in cmd windows
    ... But the piece de resistance was the "start" command, ... - Have all code for the one project in one single batch file. ... @echo off ... echo:: ERROR ERROR ERROR ERROR ...
    (microsoft.public.win2000.general)
  • Re: File Size Check
    ... the batch ended and was done. ... del para2.txt ... echo open ... echo>> para2.txt GET %FileName% ...
    (microsoft.public.scripting.vbscript)
  • Re: Batch File to manipulate path and file name
    ... It should process any "poison" characters ... # echo Full name=%%a ... If you object to requiring two files to achieve your aim (one batch, ... How do I get from Input File Name to Output File Name Desired? ...
    (microsoft.public.windowsxp.general)
  • Re: del not working in .bat file
    ... Haven't managed yet to do away with the .bat file and run this: ... Try using the CALL command inside the batch file. ... @echo off ... executes, which calls test2.bat and that executes. ...
    (microsoft.public.vb.general.discussion)
  • Re: del not working in .bat file
    ... Try using the CALL command inside the batch file. ... @echo off ... executes, which calls test2.bat and that executes. ...
    (microsoft.public.vb.general.discussion)