Different ways to execute a binary? [on hold]
up vote
0
down vote
favorite
Are there more ways of executing Unix binaries using a terminal (command line)? Using echo
as an example:
$ /bin/echo "test"
test
$ cd /bin/
$ ./echo "test"
test
$ eval echo "test"
test
linux ubuntu command-line terminal osx
New contributor
put on hold as unclear what you're asking by Scott, Romeo Ninov, Michael Homer, Sparhawk, Wieland Nov 18 at 8:54
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
|
show 1 more comment
up vote
0
down vote
favorite
Are there more ways of executing Unix binaries using a terminal (command line)? Using echo
as an example:
$ /bin/echo "test"
test
$ cd /bin/
$ ./echo "test"
test
$ eval echo "test"
test
linux ubuntu command-line terminal osx
New contributor
put on hold as unclear what you're asking by Scott, Romeo Ninov, Michael Homer, Sparhawk, Wieland Nov 18 at 8:54
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
2
cd /; bin/echo "test"
,cd /usr/share; ../../var/log/../../bin/echo test
. If we take your two first examples as distinct, then the possibilities are endless!
– Sparhawk
Nov 18 at 3:56
do you mean "ways to execute it from a shell" or do you also mean to also include ways that are not from a shell, such as in a program that is not a shell script?
– Skaperen
Nov 18 at 4:29
execute from a shell/terminal, yeah. ill update the question. your comment was very helpful actually.
– user321532
Nov 18 at 4:31
which shell are you using? there are many and each has their own ways. and there are an "infinite" number of ways to construct commands in each of the many shells.
– Skaperen
Nov 18 at 4:48
i dont get how a similar question has been asked before and received +43 but i ask it (specific to binaries, not bash) and it gets -1? thanks anyway unix.stackexchange.com/questions/2976
– user321532
Nov 18 at 5:17
|
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Are there more ways of executing Unix binaries using a terminal (command line)? Using echo
as an example:
$ /bin/echo "test"
test
$ cd /bin/
$ ./echo "test"
test
$ eval echo "test"
test
linux ubuntu command-line terminal osx
New contributor
Are there more ways of executing Unix binaries using a terminal (command line)? Using echo
as an example:
$ /bin/echo "test"
test
$ cd /bin/
$ ./echo "test"
test
$ eval echo "test"
test
linux ubuntu command-line terminal osx
linux ubuntu command-line terminal osx
New contributor
New contributor
edited Nov 18 at 4:31
New contributor
asked Nov 18 at 3:48
user321532
61
61
New contributor
New contributor
put on hold as unclear what you're asking by Scott, Romeo Ninov, Michael Homer, Sparhawk, Wieland Nov 18 at 8:54
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as unclear what you're asking by Scott, Romeo Ninov, Michael Homer, Sparhawk, Wieland Nov 18 at 8:54
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
2
cd /; bin/echo "test"
,cd /usr/share; ../../var/log/../../bin/echo test
. If we take your two first examples as distinct, then the possibilities are endless!
– Sparhawk
Nov 18 at 3:56
do you mean "ways to execute it from a shell" or do you also mean to also include ways that are not from a shell, such as in a program that is not a shell script?
– Skaperen
Nov 18 at 4:29
execute from a shell/terminal, yeah. ill update the question. your comment was very helpful actually.
– user321532
Nov 18 at 4:31
which shell are you using? there are many and each has their own ways. and there are an "infinite" number of ways to construct commands in each of the many shells.
– Skaperen
Nov 18 at 4:48
i dont get how a similar question has been asked before and received +43 but i ask it (specific to binaries, not bash) and it gets -1? thanks anyway unix.stackexchange.com/questions/2976
– user321532
Nov 18 at 5:17
|
show 1 more comment
2
cd /; bin/echo "test"
,cd /usr/share; ../../var/log/../../bin/echo test
. If we take your two first examples as distinct, then the possibilities are endless!
– Sparhawk
Nov 18 at 3:56
do you mean "ways to execute it from a shell" or do you also mean to also include ways that are not from a shell, such as in a program that is not a shell script?
– Skaperen
Nov 18 at 4:29
execute from a shell/terminal, yeah. ill update the question. your comment was very helpful actually.
– user321532
Nov 18 at 4:31
which shell are you using? there are many and each has their own ways. and there are an "infinite" number of ways to construct commands in each of the many shells.
– Skaperen
Nov 18 at 4:48
i dont get how a similar question has been asked before and received +43 but i ask it (specific to binaries, not bash) and it gets -1? thanks anyway unix.stackexchange.com/questions/2976
– user321532
Nov 18 at 5:17
2
2
cd /; bin/echo "test"
, cd /usr/share; ../../var/log/../../bin/echo test
. If we take your two first examples as distinct, then the possibilities are endless!– Sparhawk
Nov 18 at 3:56
cd /; bin/echo "test"
, cd /usr/share; ../../var/log/../../bin/echo test
. If we take your two first examples as distinct, then the possibilities are endless!– Sparhawk
Nov 18 at 3:56
do you mean "ways to execute it from a shell" or do you also mean to also include ways that are not from a shell, such as in a program that is not a shell script?
– Skaperen
Nov 18 at 4:29
do you mean "ways to execute it from a shell" or do you also mean to also include ways that are not from a shell, such as in a program that is not a shell script?
– Skaperen
Nov 18 at 4:29
execute from a shell/terminal, yeah. ill update the question. your comment was very helpful actually.
– user321532
Nov 18 at 4:31
execute from a shell/terminal, yeah. ill update the question. your comment was very helpful actually.
– user321532
Nov 18 at 4:31
which shell are you using? there are many and each has their own ways. and there are an "infinite" number of ways to construct commands in each of the many shells.
– Skaperen
Nov 18 at 4:48
which shell are you using? there are many and each has their own ways. and there are an "infinite" number of ways to construct commands in each of the many shells.
– Skaperen
Nov 18 at 4:48
i dont get how a similar question has been asked before and received +43 but i ask it (specific to binaries, not bash) and it gets -1? thanks anyway unix.stackexchange.com/questions/2976
– user321532
Nov 18 at 5:17
i dont get how a similar question has been asked before and received +43 but i ask it (specific to binaries, not bash) and it gets -1? thanks anyway unix.stackexchange.com/questions/2976
– user321532
Nov 18 at 5:17
|
show 1 more comment
2 Answers
2
active
oldest
votes
up vote
1
down vote
There many different ways to express code in a shell command line or in a shell script line that can result in a binary being executed. They all just come down to the point of running a shell command. The shell will try to run a file if the command refers to a file. That attempt will succeed if you have permission to execute the file. The file may be a binary executable or a script that refers to its interpreter on the first line (which begins with "#!") or the file may just be plain data like text. If it is executable at that point then it will run or be interpreted. The shell has plenty of ways to express a command. The possibilities are infinite.
add a comment |
up vote
1
down vote
Please note that, as Sparhawk pointed out in the comments, the first two examples are doing basically the same (they invoke the program using its path instead of doing a path lookup) and following that logic the ways to execute a given program are virtually infinite.
Anyway, I'd say there are at least 4 different ways to execute programs[1] from a shell:
Shell builtins: some commands, such as
echo
itself in Bash, are implemented within the shell so the corresponding external utility, if exists, is not invoked.
$ echo foo
foo
Path lookup: when the shell searches the desired program in each of the directories included in the
PATH
environment variable.
$ cat <<< foo
foo
Direct invoking: when the program is invoked using its full/relative path.
$ /bin/echo foo
foo
$ ../../bin/echo foo
foo
Indirect invoking: when the program is invoked by another program (either a builtin or an external one).
$ eval echo foo
foo
$ command echo foo
foo
$ sh -c 'echo foo'
foo
1. I know you said binaries. I used a more general term because scripts can also be executed from a shell.
1
a reference to a file to be executed works the same whether the file is a script or a binary. except for sourcing the shell doesn't generally know or care.
– Skaperen
Nov 18 at 6:15
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
There many different ways to express code in a shell command line or in a shell script line that can result in a binary being executed. They all just come down to the point of running a shell command. The shell will try to run a file if the command refers to a file. That attempt will succeed if you have permission to execute the file. The file may be a binary executable or a script that refers to its interpreter on the first line (which begins with "#!") or the file may just be plain data like text. If it is executable at that point then it will run or be interpreted. The shell has plenty of ways to express a command. The possibilities are infinite.
add a comment |
up vote
1
down vote
There many different ways to express code in a shell command line or in a shell script line that can result in a binary being executed. They all just come down to the point of running a shell command. The shell will try to run a file if the command refers to a file. That attempt will succeed if you have permission to execute the file. The file may be a binary executable or a script that refers to its interpreter on the first line (which begins with "#!") or the file may just be plain data like text. If it is executable at that point then it will run or be interpreted. The shell has plenty of ways to express a command. The possibilities are infinite.
add a comment |
up vote
1
down vote
up vote
1
down vote
There many different ways to express code in a shell command line or in a shell script line that can result in a binary being executed. They all just come down to the point of running a shell command. The shell will try to run a file if the command refers to a file. That attempt will succeed if you have permission to execute the file. The file may be a binary executable or a script that refers to its interpreter on the first line (which begins with "#!") or the file may just be plain data like text. If it is executable at that point then it will run or be interpreted. The shell has plenty of ways to express a command. The possibilities are infinite.
There many different ways to express code in a shell command line or in a shell script line that can result in a binary being executed. They all just come down to the point of running a shell command. The shell will try to run a file if the command refers to a file. That attempt will succeed if you have permission to execute the file. The file may be a binary executable or a script that refers to its interpreter on the first line (which begins with "#!") or the file may just be plain data like text. If it is executable at that point then it will run or be interpreted. The shell has plenty of ways to express a command. The possibilities are infinite.
answered Nov 18 at 4:44
Skaperen
610512
610512
add a comment |
add a comment |
up vote
1
down vote
Please note that, as Sparhawk pointed out in the comments, the first two examples are doing basically the same (they invoke the program using its path instead of doing a path lookup) and following that logic the ways to execute a given program are virtually infinite.
Anyway, I'd say there are at least 4 different ways to execute programs[1] from a shell:
Shell builtins: some commands, such as
echo
itself in Bash, are implemented within the shell so the corresponding external utility, if exists, is not invoked.
$ echo foo
foo
Path lookup: when the shell searches the desired program in each of the directories included in the
PATH
environment variable.
$ cat <<< foo
foo
Direct invoking: when the program is invoked using its full/relative path.
$ /bin/echo foo
foo
$ ../../bin/echo foo
foo
Indirect invoking: when the program is invoked by another program (either a builtin or an external one).
$ eval echo foo
foo
$ command echo foo
foo
$ sh -c 'echo foo'
foo
1. I know you said binaries. I used a more general term because scripts can also be executed from a shell.
1
a reference to a file to be executed works the same whether the file is a script or a binary. except for sourcing the shell doesn't generally know or care.
– Skaperen
Nov 18 at 6:15
add a comment |
up vote
1
down vote
Please note that, as Sparhawk pointed out in the comments, the first two examples are doing basically the same (they invoke the program using its path instead of doing a path lookup) and following that logic the ways to execute a given program are virtually infinite.
Anyway, I'd say there are at least 4 different ways to execute programs[1] from a shell:
Shell builtins: some commands, such as
echo
itself in Bash, are implemented within the shell so the corresponding external utility, if exists, is not invoked.
$ echo foo
foo
Path lookup: when the shell searches the desired program in each of the directories included in the
PATH
environment variable.
$ cat <<< foo
foo
Direct invoking: when the program is invoked using its full/relative path.
$ /bin/echo foo
foo
$ ../../bin/echo foo
foo
Indirect invoking: when the program is invoked by another program (either a builtin or an external one).
$ eval echo foo
foo
$ command echo foo
foo
$ sh -c 'echo foo'
foo
1. I know you said binaries. I used a more general term because scripts can also be executed from a shell.
1
a reference to a file to be executed works the same whether the file is a script or a binary. except for sourcing the shell doesn't generally know or care.
– Skaperen
Nov 18 at 6:15
add a comment |
up vote
1
down vote
up vote
1
down vote
Please note that, as Sparhawk pointed out in the comments, the first two examples are doing basically the same (they invoke the program using its path instead of doing a path lookup) and following that logic the ways to execute a given program are virtually infinite.
Anyway, I'd say there are at least 4 different ways to execute programs[1] from a shell:
Shell builtins: some commands, such as
echo
itself in Bash, are implemented within the shell so the corresponding external utility, if exists, is not invoked.
$ echo foo
foo
Path lookup: when the shell searches the desired program in each of the directories included in the
PATH
environment variable.
$ cat <<< foo
foo
Direct invoking: when the program is invoked using its full/relative path.
$ /bin/echo foo
foo
$ ../../bin/echo foo
foo
Indirect invoking: when the program is invoked by another program (either a builtin or an external one).
$ eval echo foo
foo
$ command echo foo
foo
$ sh -c 'echo foo'
foo
1. I know you said binaries. I used a more general term because scripts can also be executed from a shell.
Please note that, as Sparhawk pointed out in the comments, the first two examples are doing basically the same (they invoke the program using its path instead of doing a path lookup) and following that logic the ways to execute a given program are virtually infinite.
Anyway, I'd say there are at least 4 different ways to execute programs[1] from a shell:
Shell builtins: some commands, such as
echo
itself in Bash, are implemented within the shell so the corresponding external utility, if exists, is not invoked.
$ echo foo
foo
Path lookup: when the shell searches the desired program in each of the directories included in the
PATH
environment variable.
$ cat <<< foo
foo
Direct invoking: when the program is invoked using its full/relative path.
$ /bin/echo foo
foo
$ ../../bin/echo foo
foo
Indirect invoking: when the program is invoked by another program (either a builtin or an external one).
$ eval echo foo
foo
$ command echo foo
foo
$ sh -c 'echo foo'
foo
1. I know you said binaries. I used a more general term because scripts can also be executed from a shell.
answered Nov 18 at 5:51
nxnev
2,5482423
2,5482423
1
a reference to a file to be executed works the same whether the file is a script or a binary. except for sourcing the shell doesn't generally know or care.
– Skaperen
Nov 18 at 6:15
add a comment |
1
a reference to a file to be executed works the same whether the file is a script or a binary. except for sourcing the shell doesn't generally know or care.
– Skaperen
Nov 18 at 6:15
1
1
a reference to a file to be executed works the same whether the file is a script or a binary. except for sourcing the shell doesn't generally know or care.
– Skaperen
Nov 18 at 6:15
a reference to a file to be executed works the same whether the file is a script or a binary. except for sourcing the shell doesn't generally know or care.
– Skaperen
Nov 18 at 6:15
add a comment |
2
cd /; bin/echo "test"
,cd /usr/share; ../../var/log/../../bin/echo test
. If we take your two first examples as distinct, then the possibilities are endless!– Sparhawk
Nov 18 at 3:56
do you mean "ways to execute it from a shell" or do you also mean to also include ways that are not from a shell, such as in a program that is not a shell script?
– Skaperen
Nov 18 at 4:29
execute from a shell/terminal, yeah. ill update the question. your comment was very helpful actually.
– user321532
Nov 18 at 4:31
which shell are you using? there are many and each has their own ways. and there are an "infinite" number of ways to construct commands in each of the many shells.
– Skaperen
Nov 18 at 4:48
i dont get how a similar question has been asked before and received +43 but i ask it (specific to binaries, not bash) and it gets -1? thanks anyway unix.stackexchange.com/questions/2976
– user321532
Nov 18 at 5:17