I'm not super familiar with exec
. I was running through some tests and examples. I wanted to pass a command written in a file to it. I'm expecting that command to be run with exec
just as if it were run directly on the commandline. Here's what I set up and tried:
[kellyry@ch12ldvela00 ~]$ cat exec_test
ls
[kellyry@ch12ldvela00 ~]$ cat exec_test | exec
[kellyry@ch12ldvela00 ~]$ cat exec_test | xargs exec
xargs: exec: No such file or directory
[kellyry@ch12ldvela00 ~]$ exec ls
exec_test file2 file3
. . .
Here's the weirdest part. Running the last line exec ls
doesn't return. That is the terminal hangs and I can't communicate with it. I'm thinking this last problem could be an issue with Mobaxterm which I'm using to ssh in to the server.
exec
here? It's possible that you've misunderstood its purpose -- see eg. https://unix.stackexchange.com/questions/160429/how-does-exec-bash-builtin-work-internally . – JigglyNaga Mar 12 '20 at 16:21man
for the command and going through a couple online examples such as: https://www.geeksforgeeks.org/exec-command-in-linux-with-examples/ made me believe I was using it correctly. Easily could be wrong. – user2183336 Mar 12 '20 at 16:27bash
command that precedes theexec ls
in that example. – JigglyNaga Mar 12 '20 at 16:32