LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-23-2010, 02:24 AM   #1
vaalu
Member
 
Registered: Jun 2007
Posts: 54

Rep: Reputation: 15
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
 
Old 08-23-2010, 02:29 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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.
 
Old 08-23-2010, 02:35 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
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.

Last edited by jschiwal; 08-23-2010 at 02:37 AM.
 
Old 08-23-2010, 04:21 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,424

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
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
 
Old 08-23-2010, 10:06 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
command execution time minil Programming 10 08-20-2010 05:59 PM
Only execute 2nd command on successufl execution of 1st command kregec05 Linux - Newbie 3 08-19-2009 11:29 AM
command execution gr8linux Linux - Newbie 14 05-28-2009 03:28 AM
can I check the execution of this command? kushalkoolwal Programming 1 10-21-2005 09:44 PM
command execution leonidas Linux - General 1 09-22-2004 01:29 AM


All times are GMT -5. The time now is 03:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration