6

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" :)

JoelFan
  • 2,165
  • 5
  • 24
  • 30
  • 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 07 '09 at 17:22
  • See also SO: http://stackoverflow.com/questions/1384398/usr-bin-perl-bad-interpreter-text-file-busy – Ether Sep 07 '09 at 15:34

3 Answers3

15

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.

chaos
  • 7,463
  • 4
  • 33
  • 49
  • 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 07 '09 at 17:43
  • Switching to vim (had to install it first) solved the problem... thanks! – JoelFan Jun 08 '09 at 00:00
  • hey, do you think this is a bug in vi that should be reported? – JoelFan Jun 08 '09 at 02: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 08 '09 at 04: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. –  Feb 25 '13 at 16:31
  • is there a way one can tell nvi to not open O_RDWR ? I hoped that :set nolock would do that but unfortunately it will not – louigi600 Feb 18 '21 at 21:43
0

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

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

Matt Simmons
  • 20,218
  • 10
  • 67
  • 114
0

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.

ericslaw
  • 1,562
  • 2
  • 13
  • 15