You'll need to download the content of the script in some way. You could do
ssh remote-host cat script.bash | bash
But that would have the same kind of problem as:
cat script.bash | bash
namely that stdin within the script would be the script itself (which could be an issue if commands within the script need to get some input from the user).
Then, a better alternative (but you'd need a shell with support for process substitution like ksh, zsh or bash) would be:
bash <(ssh remote-host cat script.bash)
Both approaches do download the script in that they retrieve its content, but they don't store it locally. Instead the content is fed to a pipe whose other end is read and interpreted by bash
.
You can also have the content of the remote script executed in the current bash process with:
eval "$(ssh remote-host cat script.bash)"
But that downloads the script fully (and stores it in memory) before running it.
The obvious solution would be to do:
. <(ssh remote-host cat script.bash)
But beware that some versions of bash have issues with that.
/path/to/nfs/mount/script.sh
from the local machine. The local machine's/test.x
file will be removed.but without downloading the script file from the remote server
: How do you expect the remote script to work on your local machine without sending the script content to the local machine ?!?commands
somehow, instead of downloading the entire script and executing it locally.set
to see that). You won't gain anything by trying to send the bare minimum to make the command work. Just think about the dependency hell if commanddo_that
depends ondo_this
to work properly. You could still do it proxy-style (e.g.do_that () { download_do_that_definition_from_server && do_that; }
), but it's still much more complicated than downloading the entire script and feeding it directly into the interpreter.