Unable to run another command from within shell script, when run from home directory
Hi All,
I am tryin to install an HP tool, HP OV from a script, to automate installation. I am using the below command in shell script called ov_exec.sh "source /tmp/LIN/oainstall.sh -i -a -precheckonly" The install package is located in /tmp/LIN/oainstall.sh oainstall.sh is the main script which calls upon subscripts based on OS and architechture. The issue I am facing is one of the subscript does not execute as it is not found, if oainstall.sh is executed form another script, located in directory other than where the oainstall.sh package is located. I tried giving absolute path to oainstall.sh in my script, still the subscript cannet be called upon, when this script is run from my home directory. But when the script is run from /tmp/LIN where oainstall packages are located, it executes fine. |
Very likely the script uses relative paths to files it requires.
It would help to know what the error message is. |
Hi blackray1,
Try replacing this line Code:
source /tmp/LIN/oainstall.sh -i -a -precheckonly Code:
oldPath=$PWD |
Code:
oldPath=$PWD Here you save your current directory address in a variable |
You wouldn't us a variable to hold the cd command though. Drop the "currentPath=" part (along with the quotes).
One problem using "source" is that it executes in the same context as the current shell, so you have to know what variables that script defines - because they will remain after the script is completed. That is the advantage of doing: Code:
... |
Quote:
I usually store all frequently used Linux command in variables. |
Storing them there is fine. Its just that they don't get executed.
|
Quote:
I wrote the code wrong currentPath="cd /tmp/LIN/" $currentPath This will execute it, sorry :) |
All times are GMT -5. The time now is 11:32 PM. |