0

I have two shell scripts; let's call those script1 and script2.

Within script1 I invoke script2. When I call script1 from my local terminal it work fine, but when I launch this command by ssh like this:

plink.exe -ssh hostname -l user -pw password "path to script1/script1"

I get this error:

script2 not found.

Now I can put an absolute path inside script1 to call script2, but the problem is that script2 calls other scripts and so on...

Can I avoid ssh look for a command from root?

2 Answers 2

1

In script1, try if adding this at the start of script helps:

cd $(dirname "$0")

Or call pushd/popd around calls to script2.

pushd $(dirname "$0")
relative_path_for_script2/script2 arg1 arg2 ...
popd

If while calling manually from terminal, you need to execute the script1 from a specific directory, say /tmp, pushd that directory instead.

Sign up to request clarification or add additional context in comments.

Comments

0

Set the PATH in script1 or in the code which invokes it.

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.