#### Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

#### TechHome

Error Messages

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

# FileOpen 1077 Error with Webbatch

Keywords:   FileOpen 1077 Error with Webbatch


### Question:

I'm evaluating WebBatch and I'm getting this on a file open:
******************************
WebBatch Error

1077: FileOpen: Open failed

WebBatch 97C
WIL Version: 2.4cbp
******************************

I initialize "inifile" with this statement:
   inifile = StrCat(DirHome(), "sbstat.ini")

sbstat.ini is in the same directory with the webbatch script.

Here's my code fragment:

   inifile = StrCat(DirHome(), "sbstat.ini")
FileClose(hf)

(Note: I've examined 'inifile' and it contains the correct path+filename value)

This is running on an NT Workstation using Personal Web Server. the directory is on a fat drive... haven't tried this on a production nt server yet...

Any recommendations?

1. Sounds like a security issue. Does the Generic web user have access to the file? Check the NTFS file settings.

2. Also I worry that you are mixing iniwrite and FileOpen operations. Usually a dicey thing to di, as NT caches the ini file contents for long periods, resulting is stale files.

To force an ini file to disk do a:

   iniwritepvt("","","","filenam.ini")


### Question (continued):

ya, I started with inireadpvt() and when that failed I switched to fileread(). (I was concerned about the ini being held open and tried the iniwritepvt("","",""..) trick but no go.

I'm going to go ahead and try the webbatch script on a 'development' nt server (fresh environment) I've given the script directory (where this puppy & it's ini are located) 'Everyone Change', 'Administrators Full'. well see what happens -- keep you posted.

Later...

I'm not having any luck. besides the problem stated above (which still doesn't work) here's the real crux of the matter: I want to execute reskit utility pulist.exe from within my webbatch script, using redirection to generate an output file for examination of three tasks in particular. the problem seems to be with creating an output file.

The relevant code is:

   outlist = 'out put file path'
thisdata = 'set to server name'

command = "pulist.exe \\%thisdata% >%outlist%"
RunWait('cmd.exe', '/c %command%')

if !FileExist(outlist)
returncode = 1
return
endif

I'm getting a return code of 1. The outlist is in the script directory where this particular guy lives.

It's running under IIS 3.0. I've even tried putting the IUSR_servername account in the Administrator's group, no go.

1. Get it doen to a SMALL test case

2. Test it as a logged on user first.

3. I don't see return code getting itself reset to 0 anyplace.

4. Try a full path to cmd.exe

5. Try a full path to the utility you are trying to run

### Resolution:

Got it!

I had to move the temporary file that I was creating and the parameter I was trying to read OUT of the directory that contained the .web file and into a directory elsewhere on the disk drive... interesting. NTFS permissions basically the same, go figure.

## Another 1077 FileOpen Error (Pathing problems)

### Question:

I looked at the 1077 error under TechSupport/WebBatch/Error Messages and tried the solution listed there but still have the problem.

I am acquiring data from a form and need to write it out to an ascii file. Everything debugged good up to the point where I open the file for appending...

tablefile = FileOpen("table.dat", "APPEND")
filewrite(tablefile,"%field1%")

I double-checked the NTFS rights for generic visitors, (ok). I moved the file that I'm trying to write to another folder(?) as described in the solution mentioned above but got the same results.

What am I missing? Do I need to build a more specific path to "table.dat"?

I would try a more specific path.

It does not seem like you are into debugging the sharing problems that will come next.

### Question (cont'd):

Sharing problems? Tell me more. Save me the pain... ;)

OK. Well, you get your script working somehow. Tests *just fine*.

But then when 80 million people start using it yuu start getting occassional errors in the FileOpen. "File could not be opened" or somesuch. What could be happening is that two (or more) copies of your script could be running at the same time (for two different users) and both of the scripts try to append to the file at the same time.

This is called a "resource conflict" and the solution is a "resource lock". The easiest solution is to use the file itself as the lock.

while 1   ; wait for resource to become avaiable
ErrorMode(@off)
tablefile = FileOpen("d:\right\there\table.dat", "APPEND")
ErrorMode(@cancel)
if tablefile!=0 then break   ; resource lock obtained. exit loop
TimeDelay(0.5)               ; no?  delay.  try again in 1/2 second
endwhile

filewrite(tablefile,field1)
FileClose(tablefile)            ; Close file AND also free resource lock


Article ID:   W12466

Filename:   FileOpen 1077 Error with Webbatch.txt
File Created: 2017:07:28:12:58:11
Last Updated: 2014:06:17:12:57:59