I'm trying to use a screen command to stack multiple commands one after another. First I run a python script and then I connect to an ssh host like this.
$HOSTNAME is slave-node-1 $arg is arg2
screen -dmS 1 sh -c "python3 pyscript1.py arg && \ ssh -i ~/.ssh/my-ssh-key user@remote-node \ "sed -i '/$HOSTNAME-pyscript1-$arg/s/$/1/' ~/test.txt"\ ;exec bash"
The reason I am using screen is because this isn't the only command I need to run and I need to be able to monitor the output of pyscript1.py as it runs.
The command is supposed to create new screen named "1", run the script pyscript1.py with the arg "arg", and only when that command finishes, I want to connect to the remote-host using that command to make a change in a file.
exec bash is meant to keep the screen open even after the commands finish.
The sed command works when I type it separately.
I am also able to create a screen named "1" using
screen -dmS 1.
I am also able to connect to the server using SSH.
However, when I run the above command, nothing happens. A new screen isn't even created.
when i run
ssh -i ~/.ssh/my-ssh-key user@remote-node "sed -i '/$HOSTNAME-pyscript1-$arg/s/$ 1/' test.txt"
I get the desired effect
but when i try
screen -dmS 1 sh -c "ssh -i ~/.ssh/my-ssh-key user@remote-node "sed -i '/$HOSTNAME-pyscript1-$arg/s/$ 1/' test.txt";exec bash"
What am I doing wrong?