Gerardo Exequiel Pozzi wrote:
David C. Rankin wrote:
<snip>
I get this new message:
[00:08 archangel:/etc] # noc fstab bash: /usr/local/bin/noc: /bin/bash: bad interpreter: Text file busy
<snip>
Text file busy?? It's a text file, it's not busy, it's either saved or you get what was present the last time it was saved, but it certainly isn't busy.
<snip>
"Text file busy" is not related with text files :)
Text refers to the "text section" of the executable. The text section of an executable is where the code resides, in other words the real program.
This message appears when a process is running and you try to overwrite it, for example:
[root@gerardo ~]# lsof -n | grep "sbin/init" init 1 root txt REG 8,1 31352 1079262 /sbin/init <<< note the 'txt' at 4th field. [root@gerardo ~]# echo 'hola' > /sbin/init -bash: /sbin/init: Text file busy
But in this case is different, you are open(2) a file in read/write mode (O_RDWR), and you tried to execute it execve(2). This is impossible.
Again lsof help to view this:
[djgera@gerardo ~]$ vi coco.sh
[djgera@gerardo ~]$ lsof -n | grep coco.sh vi 4127 djgera 4uW REG 8,6 32 113481 /home/djgera/coco.sh #### see the 'W' in 4th field. [djgera@gerardo ~]$ ./coco.sh bash: ./coco.sh: /bin/bash: bad interpreter: Text file busy
Another simple example:
[djgera@gerardo ~]$ cat coco.sh #!/bin/bash
echo "Hola mundo!" [djgera@gerardo ~]$ cat coco.c #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #define __USE_GNU #include <fcntl.h>
int main(int argc, char *argv[]) { int coco; coco = open("./coco.sh", O_RDWR); sleep(60); close(coco); return(0); } [djgera@gerardo ~]$ gcc coco.c -o coco [djgera@gerardo ~]$ ./coco & [1] 4234 [djgera@gerardo ~]$ lsof -n | grep coco.sh coco 4234 djgera 3u REG 8,6 32 113481 /home/djgera/coco.sh #### See the 'u' in 4th field. [djgera@gerardo ~]$ ./coco.sh bash: ./coco.sh: /bin/bash: bad interpreter: Text file busy
Good Luck!
(sorry my english)
Btw: if you execute the script via "bash coco.sh" will work ;) And maybe my example is ambiguous, if the openned file is not a script also can not be executed. Example: (changing the open line to /bin/ping, and executing as root [djgera@gerardo ~]$ ping bash: /bin/ping: Text file busy -- Gerardo Exequiel Pozzi ( djgera ) http://www.djgera.com.ar KeyID: 0x1B8C330D Key fingerprint = 0CAA D5D4 CD85 4434 A219 76ED 39AB 221B 1B8C 330D