LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   command execution (https://www.linuxquestions.org/questions/linux-newbie-8/command-execution-827922/)

vaalu 08-23-2010 01:24 AM

command execution
 
hi all,

I have a shell script which is executable in a folder named build. What i currently do is cd into the build directory from my home folder and do a ./make.sh ... Is there any way i can run this executable from my home directory itself??

Something like ./vaalu/ADK/build/make.sh??

the path to the make shell script is

/home/vaalu/ADK/build/make.sh

Any help would be appreciated.
Thanking you in anticipation

regards,

Vishnu Prasad H

paulsm4 08-23-2010 01:29 AM

Sure. You can type:

Quote:

vaalu/ADK/build/make.sh
<= You don't need the "."

If you need to do this often enough, you can do any of:

a) edit your .bashrc file and include value/ADK/build in your $PATH
<= that way, you can just type "make.sh"

and/or

b) Create an alias for "make.sh" (for example, "mk")

and, of course,

c) You can always create a desktop shortcut (if you use a GUI)

PS:
If you do any of this, you should definitely modify "make.sh" to "cd" into the correct directory before it tries to build anything.

jschiwal 08-23-2010 01:35 AM

The script may assume you are in the current directory. You could use "pushd ./vaalu/ADK/build" first and the "popd" afterwards. If its something you often, you can use "CTRL-R pushd" to recall it from the bash history, or enter parts of the path, and press TAB for autocompletion.

A script such as
TARGETDIR=/home/vaalu/ADK/build
RETURNDIR="$PWD"
cd "$TARGETDIR"
. ./make.sh
cd "$RETURNDIR"

in your ~/bin/ directory may automate the process for you.

grail 08-23-2010 03:21 AM

As Paul highlighted, be very careful what commands are in your script as if they are using relative paths from where you launch the script it could
get very messy ;)

catkin 08-23-2010 09:06 AM

What jschiwal and grail wrote. In this case, where the script is called make.sh, suggesting a software build utility, it is not just possible that the utility assumes the correct working directory -- it is very probable because it is such a common build programming technique.


All times are GMT -5. The time now is 04:28 AM.