When entering
./program
The shell tries to execute the program according to how it determines that the file should be executed. If it is binary, it will try to execute the input routine. If the shell detects that it is a script, for example, using
#!/bin/sh
or
or in general
the shell will pass the file (and any arguments provided) as arguments to the provided interpreter, which will then execute the script. If the interpreter specified in the path does not exist, the shell will be an error, and if the interpreter string is not found, the shell will assume that the supplied script should be executed by itself.
Team
sh program
equivalently
./program
when the first line of the program contains
#!/bin/sh
assuming / bin / sh is sh in your path (for example, it could be / system / bin / sh). Passing binary code to sh will cause sh to treat it as a shell script, which it is not, and binary as an uninterpreted shell (which is plain text). That is why you cannot use
sh program
in this context. It will also fail because the program is ruby, awk, sed, or something else that is not a shell script.
user1207217
source share