I'm stumped by an attempt at a bash redirect attempt. I am trying to run a command that takes a redirect as a subcommand of screen
, with the redirect going to the subcommand rather than to screen
.
Here is a cleaned up version of the original command:
ssh -o "StrictHostKeyChecking no" <user>@<host> 'bash -s' < my_script.sh -- -s OPTION1 -o OPTION2
That works exactly as desired. But, my attempt at running it under screen
breaks:
screen -d -m ssh -o "StrictHostKeyChecking no" <user>@<host> 'bash -s' < my_script.sh -- -s OPTION1 -o OPTION2
I can see that now the redirect is going to screen
rather than to ssh
, but I can't figure out how to make it work the way I want it.
If you have some working code, export it as a function, and call that function from inside your subshell started by
screen
. That way your code will run precisely as it would without screen involved.If your code uses variables you aren't showing us, be sure to
export
them too, so the exported function can access them.