Re: Access Denied Error -- Reading Text File in .BAT program
- From: "Pegasus \(MVP\)" <I.can@xxxxxxxxxx>
- Date: Wed, 29 Oct 2008 17:58:04 +0100
Since you can't post the whole batch file, I can only offer some hints:
- Add three statements to the batch file, two at the start, one at the
the end, so that you know when each batch file started and when
(or if!) it ended:
@echo off
set TimeMarker=%time%
echo Start %date% %TimeMarker% >> c:\test.txt
{put your code here}
echo End %date% %TimeMarker% >> c:\test.txt
If an end marker is missing then you'll know that the batch
file hung.
- When you echo data to a file, use a unique file name for each
machine that performs the "echo" function.
- To resolve the reported contradiction of a server file existing / not
existing, try to create a folder of the same name while working
on the server console.
- IMHO it is a good idea to fully qualify all data files referenced
in a batch file. Instead of writing
DEL ?-STORE.RW
I would always write
DEL "c:\Datafiles\?-STORE.RW"
"PghMark" <PghMark@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:85B7B292-E89C-47E0-BFB0-7B3778481418@xxxxxxxxxxxxxxxx
I can't send you a copy of the production program (company rules), however
the following code is a subset of what happens.
REM * PROGRAM START
:BEGIN
IF EXIST ?-STORE.RW DEL ?-STORE.RW
IF EXIST ALLSTORE.RW DEL ALLSTORE.RW
FOR /F "TOKENS=1,2 DELIMS=," %%i IN (STORELIST.CSV) DO @CALL :ADDSTORE
%%i
%%j
GOTO :EXITBAT
:ADDSTORE
IF %1 EQU -5 ECHO %2 >>E-STORE.RW
IF %1 EQU -6 ECHO %2 >>C-STORE.RW
IF %1 EQU -7 ECHO %2 >>M-STORE.RW
IF %1 EQU -8 ECHO %2 >>W-STORE.RW
GOTO :EOF
:EXITBAT
TYPE ?-STORE.RW >ALLSTORE.RW
EXIT
REM * PROGRAM END
Subsequent programs that access these ".RW" files use FOR statements to
read
in the list of stores in either a specific time zone (E,C,M,W) or the
ALLSTORE.RW file. The files are never opened for update until the next
day
when the above program runs again.
I can't duplicate the error on demand. When it happens it has never been
the same ".RW" file that has been affected, however it appears that the
file
may be locked at the time the batch program is trying to delete the
previous
day's file.
NET FILE only shows the production application server/user id as having
the
file in use. At the time that I check it there are no longer any
processes
running on the application server.
It is strange the file disappears completely after using the NET FILE
/CLOSE
option to unlock the file.
Thanks, Mark
"Pegasus (MVP)" wrote:
"PghMark" <PghMark@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:040B6729-1B2A-48DE-9F6A-51E81D225265@xxxxxxxxxxxxxxxx
I'm encountering an occasional error that is having devastating
consequences
for my production processes.
My environment Windows Server 2003. I have the .BAT program executing
on
an
applications server and all files that are created, or accessed, are
stored
on a fileserver that is shared out.
The file is accessed dozens of times daily. This error has occurred
twice
in the last couple of months.
*****
Each night I create a .TXT file, on a network share, with a list of
store
numbers that I will be processing on that evening.
When my problem occurs, the following happens on my application server:
1. I am unable to delete the previous days file (access denied)
2. I can't read the .TXT file (access denied)
3. I can't copy the .TXT file (access denied)
4. A directory shows that the .TXT file exists.
5. An IF EXIST statement, both WSH and VBScript, indicate that the
.TXT
file does not exist
If I go to the file server where the share resides:
1. NET FILE shows that the file is in use by the application server.
2. NET FILE indicates that the file is in use, but not LOCKED.
3. A directory listing of the file shows that it exists.
If I use NET FILE ######### /CLOSE the following are the results:
1. NET FILE does not show the file in use
2. A DIR command shows that the file no longer exists.
I've checked all of my event logs and there are no errors in the
application, system, or security log related to the file, or in the
time
frame when the file was orginally being deleted, then recreated.
I've "googled" the world and can not find anyone that has experienced a
similar problem.
For starters, can anyone recommend a method that would help me identify
what
is happening to the file. If I know that I pretty sure I can figure
out
how
to fix it.
Let's have a look at your batch file.
.
- References:
- Access Denied Error -- Reading Text File in .BAT program
- From: PghMark
- Re: Access Denied Error -- Reading Text File in .BAT program
- From: Pegasus \(MVP\)
- Re: Access Denied Error -- Reading Text File in .BAT program
- From: PghMark
- Access Denied Error -- Reading Text File in .BAT program
- Prev by Date: Re: Access Denied Error -- Reading Text File in .BAT program
- Next by Date: RE: Finding a Specfic File Through a Batch File
- Previous by thread: Re: Access Denied Error -- Reading Text File in .BAT program
- Next by thread: Re: Access Denied Error -- Reading Text File in .BAT program
- Index(es):
Relevant Pages
|