Inconsistent "End of file error" on "open for access "myFile.txt"

I have a script that accesses a txt file containing info needed for values in the script. Sometimes the script works flawless, but once I get the "End of file error," it won't work right anymore unless I log out and log back in or if I dump the file and rewrite it. Below is a copy of the portion of script having the problem:
+set _fileRef to open for access "Library:Preferences:MyTextFile.txt" with permission+
+ set ReadMyTextFile to read _fileRef as string+
+ close access _fileRef+
Is there a way to reset the "End of file" status so that I can access it later with the same script in one login session? I have a feeling that the first time it opens, that it reads to the end of the file and then closes the file. When it opens again the script starts to read where it left off at the end of the file. Does that sound right?
Any help would be great.

OK, it looks like if you are going to use the open for access..close access, you need to keep tack of the EOF yourself, so you can just read to the EOF - for example:
<pre title="this text can be pasted into the Script Editor" style="font-family: Monaco, 'Courier New', Courier, monospace; font-size: 10px; padding: 5px; width: 720px; color: #000000; background-color: #E0E0E0; overflow: auto"> set TheOpenFile to open for access (choose file)
try
set SomeText to paragraphs of (read TheOpenFile to eof as text)
close access TheOpenFile
on error
close access TheOpenFile
end try
choose from list SomeText with prompt "File text:" with empty selection allowed
</pre>
If there isn't any particular reason to explicitly open and close the file, you can use something like:
<pre title="this text can be pasted into the Script Editor" style="font-family: Monaco, 'Courier New', Courier, monospace; font-size: 10px; padding: 5px; width: 720px; color: #000000; background-color: #E0E0E0; overflow: auto"> set SomeText to paragraphs of (read (choose file) as text)
choose from list SomeText with prompt "File text:" with empty selection allowed
</pre>
In the above examples I used paragraphs of in order to use the choose from list, since it displays stuff like this a little bit better - see this article for a tutorial on file read/write in AppleScript.

Similar Messages

  • End of File error on .nef files

    I am beginning to see a growing number of my .nef files becoming visually corrupt in the viewer and showing the "end of file" error when opening in PS or any other application.
    The corruption does NOT seem to affect the associated .jpg file (if there is one) but I am also NOT able to generate another "clean" .jpg file with the .nef files that have become corrupt.
    I hope that I haven't confused everyone - but this issue is rather baffeling in that I can't seem to pinpoint a cause.
    My master files are stored as reference files on a server share - all shot with a Nikon D2X.
    Does anyone have an idea of what may be causing this - and better yet - is there a way to reverse the corruption?

    I do have a number of other systems that I can use to test from. THe file server is a general purpose server in my home running 10.4.x with all of the latest patches, etc.
    I am using a SanDisk card reader to ingest directly into Aperture. The corruptness appears to be random.
    I am using a Nikon D2X with a number of CF cards, usually 1 or 2GB in size. I capture recording .nef (RAW) images to the CF card.
    My workstation is a PowerMac, Dual G5, with 2.5GB processors and 2.5GB of memory. I am using MacOS 10.4.2 with all of the appropriate patches and updates.
    The Server is a PowerMac, Dual G5, with 2.5GB processors and 2.5GB of memory. The server is running MacOS 10.4.x Server, again with all of the appropriate patches and software.
    The network is Gigabit speed with one switch between my workstation and the server. The Switch is a GSM7224 L2, 24-port 10/100/1000MBps managed switch.
    The users in my home (in this case; me) log into any of a number of workstations in my home and authenticate against the server using LDAP. Once authenticated, home directories are available and stored on the server.
    This appears to be network related as I can ingest and save locally to the server and open the files without any corruption.

  • End of file error on previously opened Raw files.

    I recently had an external hard drive get damaged. Many raw files were able to be recovered but when I go to open ones I had previously manipulated in ACR I get an end of file error. It seems it's only on the previously used photos...is there a way to recover them so I can re-edit them?

    You might try IfranView - it's free. It will open corrupt images and you can visually see the extent of the corruption, e.g. 90% of the image might show, with garbage showing at the bottom.
    You could then crop the image and use that - losing the corrupt part.
    You should also consider using a cloud storage service like dropbox, google drive, box.com, Creative Cloud etc. to backup your images.
    I'd try to refrain from working from an external drive.

  • Project Won't Open - End of File error

    I have an Encore CS4 project that uses Dynamic Link to an HD Premiere Pro CS4 project and I completed it and burned a DVD 2 months ago. Now I am trying to open the Encore project so I can transcode to Blu-ray, but after 10 minutes or so I get the "End of File" error message. So I can't open the project to change anything. Thoughts?

    I had already opened the project in PPro, rendered it completely, closed it and tried again. No luck. But then I went into the Encore project folders: Sources/Transcodes and deleted the PPro project folder containing all the transcodes. Then the Encore project opened (without these transcodes). That was fine because they were the DVD transcodes and I am now building a blu-ray image.

  • End of file error, elements 12

    I've recently started getting an 'End of file' error when I try to open around a third of my RAW files in Elements 12.
    Very frustrating, as I've some decent photo's, and means I'm taking having to take photo's twice to compensate, not ideal. I wondered if it may be a space issue, so have deleted lots of files from my Toshiba laptop, and in particular edited files that use up more space.  This hasn't helped though so I'm pulling my hair out.  
    Any help would be greatly appreciated, thank you.

    Yes, definitely, the GB Project file is corrupt, delete it, empty the trash, and it would be a good idea to run some kind of disk repair program, even if it's just Disk Utility. Then create a new project file.
    Good luck --HangTime [Will Compute for Food] B-|>

  • HELP! 'unexpected end of file' error-Is there a fix?! OS 10.4.11

    Getting 'Unexpected end of file' error when trying to open a file (that's a rush job) in QuarkXpress 6.5.  I attributed it to lack of memory, so I immediately backed up all files and HD to an external drive to free up space. Restarted and prayed... Quark launched, but file won't open. Same error.
    Have: 2.1 GHz PPC G5, 1.5 GB DDR2 SDRAM  OS 10.4.11 (pre Intel)
    Capacity: 232.8GB, Available: 163GB, Used 69.6GB
    Have been searching help site for 5 hours looking for answer and am DESPERATE!  I saved changes regularly, but can't access this file at all... I've lost 2 full days & nights working on this project that has to be done in 2 days.
    Ran Disk Utility, but no success opening this specific Quark file (Quark will launch- it's just this file that's affected).  Have tried to down load Applejack, etc. but keep finding out they only support OS 10.5 or higher.  (Haven't been able to afford upgraded system since Intel requires purchase of full verions of graphics software instead of upgrades to the tune of $6k).
    PLEASE, I only know enough to be dangerous, so ANY help is GREATLY APPRECIATED! 
    Savvy folks- if I'm in the wrong place, please send me a link where I can solve this personal catastrophy.
    Many thanks-in-advance

    I think you best do over your work from scratch.  You need to make backup copies of the files regularly.  You need to have copies on multiple disks or flash drives.
    I saved changes regularly
    You should know that this isn't sufficient. You need to have multiplte copies of the file.  Backup anyone?  Could be the file structure got messed up.  Could be Quark messed up the file.
    You need to get a newer machine.  G5's are not reliable any more.  Need to see if Quark will run in compatiblity mode on an intel machine.  You should at least get an external firewire drive from owc.  Old hd's are not reliable.
    Boot in safe mode. Hold down the shift key when powering on the machine. This will run a disk repair program. Boot up will take longer as the harddrive is scanned and repaired.
    See this article:
    http://docs.info.apple.com/article.html?artnum=107393
    Or from:
        mrtotes article  :
        Boot from the OS X Install disk and from the Menu Bar choose Disk Utility. Then run "Repair Disk" and "Repair Disk Permissions" on your hard disk.
        a brody:
        https://discussions.apple.com/docs/DOC-1689
    Here the apple article on booting single user mode and using fsck. See the section on Use fsck:
    http://docs.info.apple.com/article.html?artnum=106214
    I suspect not but Perhaps Disk Warrior will be of some help:
    http://www.alsoft.com/DiskWarrior/
    Robert

  • Help with "open for access" error

    Why am I getting file wasn't found error here? (The file is on the desktop).
    try
    -- set myPrefsFile to (choose file with prompt "Select a file to read:" of type {"TEXT"})
    open for access (file "10.3.9:desktop:myFile")
    set fileContents to (read file "10.3.9:desktop:myFile")
    close access file "10.3.9:desktop:myFile"
    display dialog fileContents
    on error Error_Message
    display dialog Error_Message
    end try
    Lennox

    1. You need to specify the correct path and extension. For example:
    10.3.9:Users:username:Desktop:myFile.txt
    2. You shouldn't need to use 'open for access' if you're only going to read the file.
    I don't have any additional suggestions for your other script.
    (36335)

  • Photoshop CS4 "Cannot save due to an end-of-file error" Help

    This problem occurs daily, probably 15-20 times per project. I take on normally 3-4 projects per day, so you can see how annoying this is. Basically when I'm saving, I get a dialogue box that says "Cannot save your file due to an end-of-file error" or something to that extent. I would love to resolve this, this problem is persistent and it's driving me out of my mind I'm saving to a network, if that has any correlation. Thanks in advance   
         Chris

    This is the boilerplate text often used in connection to saving to a network (please NOTE the part where it explains that normally, it does work, but that it is impossible to troubleshoot someone else's network remotely, and that's why it's not supported by Adobe):
    If you are opening files over a network or saving them to a network server, please cease and desist immediately in the event you are currently experiencing problems with one or more files. Working across a network is not supported.
    See: 
    http://kb2.adobe.com/cps/406/kb406793.html
      Copy the CLOSED file from your server to your local hard disk, work on it, save it again to your local hard disk, close it, and copy the closed file back to the server.
         Of course, the fact that Adobe does not support working across a network does not necessarily mean it won't work.   It should.
        Adobe's position is that there are too many variables in a network environment for them to guarantee that everything will work correctly in every network, especially given the fact that if something does not work properly, it's probably the network's fault, and Adobe has no way of troubleshooting your network.
      If you can't work locally, you are on your own, and if something happens, you're on your own. If you must work from a server, make sure your network administrator is a competent professional.
    When problems arise, a lot of valuable work can be lost.

  • Oraclejsp unexpected end of file error

    I am getting an OracleJsp Unexpected End of File error when I use the <logic:present name="add"> <html:form action="myAction" /> </logic:present> tag. "add" is referring to something that was set in a struts action (ie: request.setAttribute("add", "present")). I've even tried a scriplet that checks request.setAttribute and I get the same error. Any ideas? Thanks.

    Often, file headers get smurfed. Photoshop is very critical of these headers.
    JPEG's seem to be very sensitive to these errors. My trick is to open in a more liberal program, like ThumbsPlus, IrfanView, or PhotoImpact, and then just do a Save, keeping the JPEG compression levels low. This nearly always clears things up for PS.
    Good luck,
    Hunt

  • Unexpected End of File Error

    I am getting a Could not open due to unexpected end of file error messages on a bunch of jpg's I am receiving via email. The files open in Microsoft Office Picture Manager.

    Often, file headers get smurfed. Photoshop is very critical of these headers.
    JPEG's seem to be very sensitive to these errors. My trick is to open in a more liberal program, like ThumbsPlus, IrfanView, or PhotoImpact, and then just do a Save, keeping the JPEG compression levels low. This nearly always clears things up for PS.
    Good luck,
    Hunt

  • PROTOOLS LE: end of file error (-39) MUST ESTABLISH NEW SESSIONS

    i messed up big time...
    saved my protools files to an external hard drive which was not set up as an audio drive. now i can't open any of my protools sessions. i get an "logic end-of-file error (-39)" message.
    i have tried opening back up sessions, verified / repaired permissions, saved back to the original location on my internal drive....all sorts of things.
    i have been importing the audio files into new sessions and arranging them, but this is really really time consuming, and frustrating, as many of the tracks are not "zero-lined".
    if anyone has a solution for somehow extracting the session/setup information, that would be great.

    Hi,
    In order to increase the max session, I would request you to set the following on your
    context.properties.
    context.global.sessionmgr.initArgs=maxSessions=2000,,timeOut=300,reap
    Interval=150
    Also, on the servlets.properties.
    servlets.sessionmgr.initArgs=maxSessions=2000,timeOut=300,reapInterval=150
    Note : Stop/start the server to take the new value.
    For more info. check below link.
    http://docs.iplanet.com/docs/manuals/enterprise/41/servlets/a-sess.htm#17031
    Regards,
    Daks.

  • Logical end of file error

    I am getting a "logical end of file error =39" message when trying to export audio to SDII for making a time stamped (BWF) . Any ideas?

    How long is the wedding video?
    My standard list of things to do first...
    Run MacJanitor (free download) to do all the Unix Cron Maintenance scripts.
    Run Disk Utility (Applications -> Utilities) and repair disk permissions on your start up drive (typically your internal drive). Also verify any other drives mounted on the system.
    Run Preferential Treatment (free download) to check for corrupt/damaged application and system preference files.
    Run Cache Out X (free download) to clear all system and application caches.
    Reboot your Mac.
    If you still can not get it to run correctly, next thing to try is to throw out the iDVD preference file (don't forget to change back those preferences you want different from the defaults next time you run it). If it still doesn't work, then I would suggest you reinstall iDVD.
    Patrick

  • End of file error using modified version Cont Pattern Input.

    Hi. I am using the Cont Pattern Input example, which is modified to write the Data Read to a file on the hard drive. A wire is connected from the Data Read to a "Write to I16 subVI" which is also modified to be a "Write to U8 subVI". It writes problem free to the file specified until the 2.1 GB when it displays a Error 4 "End of File Error". There is ample space on the hard drive. How do we get rid of this error as we would eventually need to write up to 60 GB of data?

    Unfortunately, the only thing to do is get a different operating system. I seem to recall that Windows has a fixed limit on file size of about 2G.
    Is there any way you can logically break the data you're collecting into smaller logical units? Alternately, you could structure your code to write to one file till it fills and automatically switch to a second, and a third and so on. As long as the routine that you write for working with these huge datasets keeps track of the various pieces of data it could all work as though it were all in one very very very large file.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • How to resolve Unexpected End of file error in Web Crawling

    how to resolve Unexpected End of file error in Web Crawling....
    I am getting java.net.SocketException :Unexpected End of file error in Web Crawling.
    How to get rid of this error.
    Please help anybody ASAP.

    1. Handle this exception - not recommended since you will be creating an exception handling overhead unnecessarily.
    2. Check for EOF using available() method in InputStream. It returns 0 if there are no bytes to read.

  • [Flat File Source [2]] Error: Cannot open the datafile "VendorPurchases20050512.txt".

    hi
    I'm trying to use foreachloop container in order to read the data that i have in several txt files and upload it into MRR table. 
    when i'm trying to run the package, i'm getting the following error: 
    [Flat File Source [2]] Warning: The system cannot find the file specified.
    [Flat File Source [2]] Error: Cannot open the datafile "VendorPurchases20050512.txt".
    [SSIS.Pipeline] Error: Flat File Source failed the pre-execute phase and returned error code 0xC020200E.
    I don't know what's the problem since it was working before.In the flat file connection manager i defined all the path including the name of the file.
    I'll be happy for assistance
    thanks
    Yaron

    Hi Yaron,
    Does the file stored in local file system or a share folder on remote server? If you can load data from a file in local computer, but cannot load data from a file in a remote computer, the issue may be caused by the Kerberos authentication. In this condition,
    check the following points:
    Enable SQL Server for Kerberos
    Check delegation settings for SQL Server service account and Computer
    Add Host SPNs for FileShare Server and SQL Server
    References:
    http://msdn.microsoft.com/en-us/library/dd568720.aspx
    http://msdn.microsoft.com/en-us/library/ms191153.aspx
    Regards,
    Mike Yin
    TechNet Community Support

Maybe you are looking for