0

I want to run a script a.sh that will do the following steps -

  1. Run few commands
  2. Call another shell script b.sh in the same server - server01
  3. b.sh will login to another server - server02 and run the commands that follow.

I am able to do till step 2 correctly. In step 3, I am able to loin to another server but it stops there. It does not run the steps that follow.

Have a look at the two scripts.

a.sh

cd ~/sample/home && python helloworld.py
#!/bin/bash
cd ~/sample/ && ./b.sh

b.sh

ssh [email protected]
echo "In server02"

Both a.sh and b.sh are in the same server, that is server01.com. Here, I want a.sh to run in server01 and then b.sh to run in server01. Once b.sh runs, it should do ssh to server02 and print "In server02".

I am able to do till ssh to server02. After that it is not printing "In server02" in server02.

Is there a way to do it?

0

1 Answer 1

0

Use a heredoc.

ssh [email protected] << EOF
  echo "In server02"
EOF
Sign up to request clarification or add additional context in comments.

1 Comment

In How to Answer, note the section "Answer Well-Asked Questions", and therein the bullet point regarding questions which "have been asked and answered many times before".

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.