In this post, I would demo how to solve the following error when executing a script in linux/unix/macos systems:
[root@kube-117 xxx]# ./h1.lua -bash: ./h1.lua: Insufficient permissions
2. The solution
You should check the first line(shebang line) inside the script, for me, this is the first line:
[root@kube-117 xxx]# cat h1.lua #!/usr/local/bin/lua local i=0 while 1 do i = i+1 if i>10000000 then print(i) break end end
But when I type
which lua to determine the lua engine, I got this:
[root@kube-117 xxx]# which lua /usr/bin/lua
So the solution is to change the first line of the script from:
One more thing about the
shebang line :
The shebang is a special character sequence in a script file that specifies which program should be called to run the script. … Many scripting languages, such as Perl, use the # character to indicate the beginning of a comment line that should be ignored by the interpreter.
The name shebang for the distinctive two characters comes from an inexact contraction of SHArp bang or haSH bang, referring to the two typical Unix names for them. Another theory on the sh in shebang is that it is from the default shell sh, usually invoked with shebang.
In this post, I demonstrated how to solve the
Insufficient permissions problem when executing a bash script in linux system, the key point is to check the first line of the script and make sure the path is correct. That’s it, thanks for your reading.