viewpoint-particle

Author Topic: Help with FileAppend.  (Read 10754 times)

morenos1

  • Jr. Member
  • **
  • Posts: 84
Help with FileAppend.
« on: January 16, 2014, 01:31:50 pm »
Simple script which worked for a long time.

I get a 1014 Fileappend I/O error when running this script.

IF FileExist("\\server\share\wstations.all")
 FileDelete ("\\server\share\Wstations.all")
EndIf

FileAppend("\\server\share\*.txt", "\\server\share\wstations.all")
Display(5, "I N F O", "Output text file WSTATIONS.ALL has been created...")

Nobody is accessing the output file .....

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Help with FileAppend.
« Reply #1 on: January 16, 2014, 01:45:29 pm »
FileExist will return the value 2 if the file is in fact in use. This code can be used to determine of the script thinks the file is in use:

Code: Winbatch
DebugTrace(@on, 'trace.txt') ;DEBUGGING ONLY
ret = FileExist("\\server\share\wstations.all")
if ret == 1
   FileDelete ("\\server\share\Wstations.all")
elseif ret == 2
  Pause("Notice","File is ucuurently in use...")
  Exit
endif

FileAppend("\\server\share\*.txt", "\\server\share\wstations.all")
Display(5, "I N F O", "Output text file WSTATIONS.ALL has been created...")
Exit

If the code still fails, post the resulting trace.txt file.
Deana F.
Technical Support
Wilson WindowWare Inc.

morenos1

  • Jr. Member
  • **
  • Posts: 84
Re: Help with FileAppend.
« Reply #2 on: January 16, 2014, 01:52:25 pm »
Trace file ...

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Help with FileAppend.
« Reply #3 on: January 17, 2014, 11:17:27 am »
I was hoping the trace.txt file would contain extended error information. However most of the extended information is stale and left over errors from previous versions of WinBatch.

Does the error message offer the option to select a button titled "More Error info"?

You also mentioned that this script has been working fine. What has changed exactly? Are you still running on the same workstation using the same user account? Can you confirm that the remote directory or files are not Read Only.
Deana F.
Technical Support
Wilson WindowWare Inc.

morenos1

  • Jr. Member
  • **
  • Posts: 84
Re: Help with FileAppend.
« Reply #4 on: January 17, 2014, 12:36:56 pm »
The "More Info" is greyed out.

The files are not "Read Only".

The output file gets created with 1 line of text only.

I can not remember the last time I needed to run this script and, it worked.

A lot has changed, (windows updates, WinBatch updates) this is a Win7 system.

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Help with FileAppend.
« Reply #5 on: January 17, 2014, 01:28:07 pm »
Wait I thought you were getting an error? Are you saying you get an error yet the output file still gets created?

Start by manually deleting the wstations.all file on the remote share. Test again.
Deana F.
Technical Support
Wilson WindowWare Inc.

morenos1

  • Jr. Member
  • **
  • Posts: 84
Re: Help with FileAppend.
« Reply #6 on: January 17, 2014, 02:10:50 pm »
I tried deleting the file already.

Yes, I get the error but, still the file gets created with just 1 line appended ...

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Help with FileAppend.
« Reply #7 on: January 17, 2014, 02:29:22 pm »
Okay if you still get the error even after manually deleting the target file I suspect the script is unable to open/read one of the *.txt files.

Maybe use this code to track down which file is causing the issue:

Code: Winbatch
filelist = FileItemize("\\Server\Public\FileAppendTest\*.txt")
For x = 1 to Itemcount( filelist, @tab)
    file = ItemExtract( x, filelist, @tab )
    ret = FileExist( file )
    if ret == 2
     Pause("Uh oh! File is currently in use...", file)
     Exit
   endif
Next
 
Deana F.
Technical Support
Wilson WindowWare Inc.

morenos1

  • Jr. Member
  • **
  • Posts: 84
Re: Help with FileAppend.
« Reply #8 on: January 21, 2014, 07:29:41 am »
I ran this. It did not find any problems .....

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Help with FileAppend.
« Reply #9 on: January 21, 2014, 09:59:35 am »
I am running out of ideas. I am beginning to suspect a hardware issue, when trying to access the remote network share. I will need to consult with the developers on this one.

You mentioned that this code has previously worked....What has changed if anything?
Deana F.
Technical Support
Wilson WindowWare Inc.

morenos1

  • Jr. Member
  • **
  • Posts: 84
Re: Help with FileAppend.
« Reply #10 on: January 21, 2014, 10:24:37 am »
Just Windows7 Windows 2008 on the server side .....

If I direct the script to a different machine, the error still comes up ...

The file gets created with just 1 line.

If I point the file to a local drive, it runs fine ....

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Help with FileAppend.
« Reply #11 on: January 21, 2014, 10:35:49 am »
Deana F.
Technical Support
Wilson WindowWare Inc.

morenos1

  • Jr. Member
  • **
  • Posts: 84
Re: Help with FileAppend.
« Reply #12 on: January 21, 2014, 11:05:33 am »
Thank You. I will look into my PC ........

td

  • Tech Support
  • *****
  • Posts: 3985
    • WinBatch
Re: Help with FileAppend.
« Reply #13 on: January 21, 2014, 11:47:21 am »
Just Windows7 Windows 2008 on the server side .....

If I direct the script to a different machine, the error still comes up ...

The file gets created with just 1 line.
Fine but you left out an important detail i.e., what was  the source of the contents of that line? Is the line nothing more than a CRLF, is it the first line of one of the text files being appended or is it the entire contents of a file?
If I point the file to a local drive, it runs fine ....

Windows 7 and 2008 are  big differences.  The source of many Windows 7 related problems is UAC.  Many folder share issues are permissions related.  You can try to diagnose these issues by manually attempting to perform some of the tasks your script is performing.  For example, you can try to open a text file on the share in a standard text editor with the same account and elevation level as your script runs under.  If that works, you can try editing the file and then checking if you have permission to save it.

Another source of shared folder problems, as previously alluded to, is hardware issues.  These are hard to diagnose because they can be either intermittent or only occur under a difficult to determine set of circumstances. 

FWIW, I did use your script successfully after substituting server and share values appropriate for my LAN  on a Window 7 system accessing a share on a Windows 2008 server.
   
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

  • Tech Support
  • *****
  • Posts: 3985
    • WinBatch
Re: Help with FileAppend.
« Reply #14 on: January 21, 2014, 02:37:33 pm »
Forgot to mention another known cause of folder sharing issues.  In th resent past there has been at least one case of a well known anti-virus utility with a buggy device driver hook that caused share read/write access problems somewhat similar to what has been describe here.  Fortunately in that case, the problem had already been reported to the the providers of that software and they had a software update available to correct the issue.   
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

  • Tech Support
  • *****
  • Posts: 3985
    • WinBatch
Re: Help with FileAppend.
« Reply #15 on: January 21, 2014, 03:31:57 pm »
...and since the 1014 error only occurs when a file read or write is attempted there is some remote possibility that one of the files being accessed is corrupt because of a bad disk sector or something.   
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Help with FileAppend.
« Reply #16 on: January 21, 2014, 03:37:52 pm »
Based on Tonys response about a possible corrupt file...You could maybe use this code to see if each of the txt files are readable:

Code: Winbatch
filelist = FileItemize("\\Server\Public\FileAppendTest\*.txt")
For x = 1 to Itemcount( filelist, @tab)
    file = ItemExtract( x, filelist, @tab )
    ErrorMode(@off)
    ret =  FileOpen( file, "READ" )
    ErrorMode(@cancel)
    if ret == 0
     Pause("Uh oh! File is Un-readable...", file)
     Exit
   endif
Next
Deana F.
Technical Support
Wilson WindowWare Inc.

morenos1

  • Jr. Member
  • **
  • Posts: 84
Re: Help with FileAppend.
« Reply #17 on: January 22, 2014, 07:00:59 am »
Testing with this script I get the error on the first TXT file. However, I can open that same file with any text editor .....

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Help with FileAppend.
« Reply #18 on: January 22, 2014, 08:33:12 am »
Testing with this script I get the error on the first TXT file. However, I can open that same file with any text editor .....

Okay so maybe we are getting somewhere. Please provide answers to all of the following:

Are you logged in to a standard user account?
Does this user account have read/write access to that remote share?
Can you please remove ErrorMode from around the FileOpen and run the script again with DebugTrace enabled.

Code: Winbatch
DebugTrace(@on,"trace-fileopen.txt")
filelist = FileItemize("\\server\share\*.txt")
For x = 1 to Itemcount( filelist, @tab)
    file = ItemExtract( x, filelist, @tab )
    ret =  FileOpen( file, "READ" )    
    if ret == 0
     Pause("Uh oh! File is Un-readable...", file)
     Exit
   endif
Next
 

Post the resulting trace-fileopen.txt and answers to the questions above.
Deana F.
Technical Support
Wilson WindowWare Inc.

morenos1

  • Jr. Member
  • **
  • Posts: 84
Re: Help with FileAppend.
« Reply #19 on: January 22, 2014, 09:23:30 am »
I am a "local administrator" account.

I have full rights to the share. I can create/change/delete anything from that share.

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Help with FileAppend.
« Reply #20 on: January 22, 2014, 09:46:14 am »
Strange, the wwwbatch.ini stuff is missing from the end of the trace file...Did you happen to remove it?

In the previous script, I forgot to add the DirChange to the remote share. That could be causing the FileOpen Error. ( However, I wonder why the extended error information is not getting written to the trace file. )

Anyhow, Please try running this code:

Code: Winbatch
;test.wbt
DebugTrace(@on,"trace-fileopen2.txt")
DirChange("\\server\share\")  ;!!!!!!!!!!!!!!!!!!!!! MODIFY TO FIT YOUR NEEDS !!!!!!!!!!!!!!!!!!!!!!!!!
filelist = FileItemize("*.txt")
For x = 1 to Itemcount( filelist, @tab)
    file = ItemExtract( x, filelist, @tab )
    handle =  FileOpen( file, "READ" )    
    line = FileRead(handle)
    FileClose(handle)
Next
;Now try to write a dummy file to the remote share
handle = FileOpen("_DELETEME.TXT","WRITE")
FileWrite(handle, "TEST")
FileClose(handle)
FileDelete("_DELETEME.TXT")
 

Post  UNMODIFIED trace-fileopen2.txt.

Thanks in advance.

Deana F.
Technical Support
Wilson WindowWare Inc.

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Help with FileAppend.
« Reply #21 on: January 22, 2014, 12:52:00 pm »
In addition, upon the 1077 error I would expect the error dialog to have a More Error Info button. Click it and post exactly what you see displayed.
Deana F.
Technical Support
Wilson WindowWare Inc.