Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For ages I've gotten used to editing Perl CGI scripts in "vi" and simultaneously having a browser open to test them. Lately, I've been getting "500" server errors when I do that, and when I run the script from the shell, I get "bad interpreter: Text file busy". The only solution is to exit "vi" whenever I want to test the script, which is a royal pain and should be totally unnecessary. What's up with that? I'm running a Debian server, which I keep updated regularly, and I'm assuming it started with some so-called "upgrade" :)

share|improve this question
A quick trip to Google suggests dos vs. unix line-ending problems or NFS/Samba shares. Neither seems really relevant to your situation, but I'll mention them here as a shot in the dark. – Telemachus Jun 7 '09 at 17:22
See also SO:… – Ether Sep 7 '09 at 15:34
up vote 13 down vote accepted

You appear to be having this issue, which is because at some point nvi started opening files O_RDWR instead of O_RDONLY.

If your vi is in fact nvi, I'd try using a different vi, say vim.

share|improve this answer
Nice catch. Your Google-Fu is strong. (I'm annoyed at myself for focusing on the error message, Perl and cgi rather than vi/vim. Rookie mistake.) – Telemachus Jun 7 '09 at 17:43
Switching to vim (had to install it first) solved the problem... thanks! – JoelFan Jun 8 '09 at 0:00
hey, do you think this is a bug in vi that should be reported? – JoelFan Jun 8 '09 at 2:24
I'm not sure "bug" is exactly right, since I'm sure someone changed nvi's open mode for a reason, but it's probably at least worth opening a conversation about. – chaos Jun 8 '09 at 4:50
You're right. I've been getting text file busy errors for a while and this was my Smultron editor that was changing line endings. Since I modified smultron parameters (Unix LF) these errors haven't occured any more. – user161751 Feb 25 '13 at 16:31

That's bizarre. Are you writing it before you attempt to refresh it?

Also, can you 'cat' the file while it's open?

share|improve this answer

We run into this when editing CGIs...

the #! interpreter line gets Ctrl-M on it somehow,
rendering the executable not found.

It looks like a perl error but is really the 'she-bang' interpreter line having 'nearly' invisible characters at the end.

In our case, we found this after the file was written. try using dos2unix command to copy to another name and try hitting that. If it works, you've found your root cause.

Sorry to say that I have no real workaround except to recognise the problem when I see it.

--edit-- Our error message is usually: scriptname: file not found NOT the 'file busy' mentioned in the question.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.