I have a shell script in a Unix environment, which itself calls other scripts (which they call other scripts), that I want to call from Windows using the task scheduler. You can imagine something like this:
myMainScript.sh (in /myFolder/myOtherFolder)
Inside this, I make calls like:
#!/bin/bash
cd /myFolder/myOtherFolder <-- this is to provide the context
cd otherSubFolder <-- entering a subfolder
myOtherScript.sh <-- calling script in subfolder
Please note that myOtherScript.sh
will also call other scripts, inside the same subfolder, which may eventually call other scripts and I can't modify those since they are "official" scripts I have no rights on.
When I run this script from a Shell console, everything works fine.
When I run this script from plink
, it raises me an error on the first command:
myOtherScript.sh: command not found
I hence tried to provide the absolute path, and instead of calling
myOtherScript.sh
... I call
/myFolder/myOtherFolder/otherSubFolder/myOtherScript.sh
In this case, the script is found and run, but then I have the same issue with the scripts which are called inside myOtherScript.sh
(on which I have no modification rights).
I have also tried to put all the content of myMainScript.sh
inside pushd + popd
(providing the context /myFolder/myOtherFolder
), but still no luck.
Can anyone lead me through the right direction?
P.s. just in case it helps, this is the way I call the script using plink
(the call works, as I can read the logs of the command prompt showing that it's logged to the Unix environment):
"R:\tools\plink.exe" user@server-pw myPassword -sh -x "/myFolder/myOtherFolder/myMainScript.sh"