/usr/bin/perl: bad interpreter: Text file busy
I'd guess you encountered this issue.
The Linux kernel will generate a bad interpreter: Text file busy
error if your Perl script (or any other kind of script) is open for writing when you try to execute it.
You don't say what the disk-intensive processes were doing. Is it possible one of them had the script open for read+write access (even if it wasn't actually writing anything)?
Why does this script work in the current directory but fail when placed in the path?
The .
command is not normally used to run standalone scripts, and that seems to be what is confusing you. .
is more typically used interactively to add new bindings to your environment (e.g. defining shell functions). It is also used to similar effect within scripts (e.g. to load a script "library").
Once you mark the script executable (per the comments on your question), you should be able to run it equally well from the current directory (e.g. ./safe.sh filename
) or from wherever it is in the path (e.g. safe.sh filename
).
You may want to remove .sh
from the name, to fit with the usual conventions of command names.
BTW: I note that you mistakenly capitalize If
in the script.
Cygwin usr/bin/perl: bad interpreter : Permission denied
You probably saved the Perl script with DOS style line endings. The shell is looking for a file called /usr/bin/perl<CR>
.
Save your files with Unix-style line endings. My .vimrc
which I use with my natively compiled vim
and gvim
has:
set fileformat=unix
set fileformats=unix,dos
Check your editor's settings for the appropriate options.
To fix line endings in a particular file, use $ dos2unix filename
.
Can't exec bin : Bad file descriptor (Perl)
The error message comes from Shell
. I don't know what anyone thinks they are gaining by using Shell
instead of the more traditional system
/qx
/pipe open/IPC::Open3
toolkit, and in particular I don't see what you are gaining by using Shell
.
Try the more traditional system call
@args = ("50%x50%", $Src, "new_image.png");
system("convert", @args) and warn "convert @args: exit code was $?";
and see if you get a more traditional error message.
Jenkins durable task plugin pipeline Text file busy
The issue here appears to be caused by a Java bug, https://bugs.openjdk.java.net/browse/JDK-8068370.
The issue is possible when multiple threads open a file for writing, close it, and then execute them (each thread using its own file). Even if all files are closed "properly", due to how file handles work around fork/exec, a child process in one thread may inherit the handle to anther thread's open file, and thus break that thread's later subprocess call.
See similar issues:
- https://issues.jenkins-ci.org/browse/JENKINS-53387
- https://issues.jenkins-ci.org/browse/JENKINS-48258?focusedCommentId=324590&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-324590
./configure : /bin/sh^M : bad interpreter
To fix, open your script with vi or vim and enter in vi command mode (key Esc), then type this:
:set fileformat=unix
Finally save it
:x!
or :wq!
shell script: bad interpreter: No such file or directory when using pwd
Better do :
#!/bin/bash
count=0
dir="$PWD"
echo "$dir"
for file in "$dir"/*
do
if [[ -f $file ]]
then
((count++))
fi
done
echo $count
or a simplest/shortest solution :
#!/bin/bash
echo "$PWD"
for file; do
[[ -f $file ]] && ((count++))
done
echo $count
Related Topics
What Is the Linux Built-In Driver Load Order
Why Do the Md5 Hashes of Two Tarballs of the Same File Differ
Find Out If File Has Been Modified Within the Last 2 Minutes
Getting Current Path in Variable and Using It
Merging Through Fuzzy Matching of Variables in R
Telnet to Login with Username and Password to Mail Server
Openssl Encoding Errors While Converting Cer to Pem
Fork() Failing with Out of Memory Error
How to Get Docker Container Id from Within the Container with Cgroup V2
Force a Shell Script to Fflush
Docker Alpine Executable Binary Not Found Even If in Path
How to Use Both 64 Bit and 32 Bit Instructions in the Same Executable in 64 Bit Linux
/Usr/Bin/Perl: Bad Interpreter: Text File Busy
How to Create a JSON Web Token (Jwt) Using Openssl Shell Commands
Binary Data Over Serial Terminal
Check That There Are at Least Two Arguments Given in a Bash Script