0

I created a shell script (Script 1) that I need to execute in server A; using Script 1, I need to execute another shell script (Script 2) that resides in Server B.

I am able to do so with the following line:

result=$(ssh ServerB /path/to/script/Script2.sh 2020-01-01 2020-03-12)

The problem is that Script 2, which I do not have edit access, calls another shell script using ./Script3 , I am getting an error stating

"./Script3 : Not found"

I believe the reason behind that is that it is looking for ./Script3 within Server A, rather than looking for it in Server B

How should I execute script 1 to avoid this?

Thanks in advance

1
  • It's looking for it on Server B. But it's looking for it in your current directory, which is your home directory. The script is probably in /path/to/script Commented Mar 12, 2020 at 18:59

1 Answer 1

1

It's looking for it in the . directory on Server B. Since you didn't change directory, the current directory is your home directory, not the directory containing the scripts. Either change Script2.sh to use the full path to Script3 instead of ./Script3, or you should change to the directory containing the scripts before running them.

result=$(ssh ServerB 'cd /path/to/script; ./Script2.sh 2020-01-01 2020-03-12')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.