Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » controlling windows batch files
Closed Thread
Old 09-08-2008, 12:00 PM   #1 (permalink)
 
Newb Techie

Join Date: Jul 2008

Posts: 11

tmshort is on a distinguished road

Default

I am reading up on Windows batch files and have not yet seen what I need.
1) How do I check to see if a file exists?
2) How do I wait to keep the batch file from using too much cpu time?
Here is the basic concept:

echo starting ftp processor
cd c:\ftpdir
:top

if exists put*.txt // how do I check for this
ftp -sut_<postfix>.txt // this should be dash s colon put, no happy face intended
del put_<postfix>.txt
end if // for if exists put.txt

sleep 6000 // how do I wait for six seconds
goto top

An existing program creates files such as put_abc.txt in the directory. The file contains the specs to perform an FTP operation. The file name may be put_def.txt, put_efg.txt, etc.

I see the "find" command, but have not yet figured out how to use it in this context.

From looking at the else statement, its a single line command so I may have to do something like:

if exists put*.txt
call putfile.bat

Is that correct?

I just discovered PowerShell. Is PowerShell much better?

After more readings, I developed two files for my ftp operations as shown below. The get getlock operation is successful.

The problem is that after doing the getlock ftp operation, my command window is left in ftp mode showing the ftp prompt. It does not execute the if exist statement. When I type in "quit" to get out of the ftp mode, the batch file seems to continue running but does not do what I expect. I have tried putting a bye and quit command in both the batch file and in the ftp control file to no avail. Here are the two files:

batch file:

@echo on

echo ftp test batch

ftp -v -s:getlock.txt

if exist lock.txt (
echo.
echo COMPUTER BUSY, WILL TRY LATER
echo.
) else (
for %%a in (put*.txt ) do (
echo.
echo putting some files
ftp -v s:%%a
echo.
)
)

contents of getlock.txt

open <my server>
<my user id>
<my password>
cd incoming
get lock.txt


Thanks for your time.

New discovery, for me that is.
If the file lock.txt exists on the server I don't want to send data. However, the attempt to do an FTP get for the file lock.txt from the other computer always creates a local file called lock.txt. The size of the local file is 0 (zero bytes) if the file on the server does not exist.

Is there a way I can supress that file creation. If not, how do I test for a zero length file in a batch file?

Regardless, thank you to Saxon for consolodating my posts. I appreciate the links, but I cannot buy things to make this project work. I just have to make it work. I will keep looking. Thanks for your time.

Last edited by Trotter; 09-08-2008 at 11:07 PM. Reason: Merged
tmshort is offline  
Old 09-08-2008, 11:07 PM   #2 (permalink)
Trotter's Avatar
 

Join Date: Jan 2005

Location: The South

Posts: 19,894

Trotter is a name known to allTrotter is a name known to allTrotter is a name known to allTrotter is a name known to allTrotter is a name known to allTrotter is a name known to all

Default Re: controlling windows batch files

Your "message" is regarded as spam here. Spam can get you banned.
__________________
R.I.P. Danny L. Trotter , 14 Nov 1945 - 4 Sept 2009




DFI LanParty-UT SLI-D - Windows 7 64-bit - AMD Athlon X2 4200+ w/CNPS9500
4GB RAM(4x1GB) - Razer Lachesis - EVGA GTX 260 Core 216 896MB


>>>> I am looking for donated DDR2 (link) <<<<

< < < < < If I've been helpful, rep me. . . .
Trotter is offline  
Old 09-09-2008, 07:44 AM   #3 (permalink)
 
Newb Techie

Join Date: Jul 2008

Posts: 11

tmshort is on a distinguished road

Default Re: controlling windows batch files

I do not see any reason why what I wrote would be regarded as spam. A private email suggested language, but I did not write anything inappropraite. Please explain.
tmshort is offline  
Old 09-09-2008, 01:52 PM   #4 (permalink)
Mak213's Avatar
 

Join Date: Sep 2004

Location: C:\Windows\System32

Posts: 25,651

Mak213 is a name known to allMak213 is a name known to allMak213 is a name known to allMak213 is a name known to allMak213 is a name known to allMak213 is a name known to all

Default Re: controlling windows batch files

Posting multiple times in a row without using the edit button which you can for 24 hours is considered spamming. You had 4 posts in a row. Never bothered to edit which you are supposed to do for the first 24 hours instead of posting again and again to put your thread at the top of the list (Also known as bumping) to be seen first.
__________________
R.I.P. Danny L. Trotter
14 Nov 1945 - 4 Sept 2009
Images created by CarnageX | Decaptured...Listen! | Visit Baezware!! | You've been Mak'd! | 儿做好
I do not accept support questions via EMail, PM, IM or my Spaces page! .:|:. This is what happens when an unstoppable force meets an immovable object.
Thanks to all the guys on the staff for your support in my time of need. Hefe you are my personal Hero for your contribution.



<<<< If I help you, or you just like what I said, rep me
Mak213 is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to install xp without the xp cd. EricB Windows Operating Systems and Software 45 03-07-2009 06:17 PM
External drive won't read in Windows XP after copying files to it from Knoppix sab3156 Linux, BSD, other *nixes & Open Source Software 4 05-13-2008 10:00 PM
Home Edition Troubles ChemicalMonkey Windows Operating Systems and Software 34 01-20-2008 09:26 PM
friends log Static_11 HijackThis Logs (finished) 11 11-25-2007 10:27 PM
Make "Add to Windows Media Player List" default for mp3 files in Vista, WMP11 imankalyan Windows Operating Systems and Software 2 11-07-2007 09:07 AM