LinuxQuestions.org
Register a domain and help support LQ
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 03-16-2010, 06:24 AM   #1
kickarzt
LQ Newbie
 
Registered: Feb 2010
Posts: 18

Rep: Reputation: 0
How to run a bashscript no matter what directory u stand in?


How to run a bashscript no matter where u stand in the directory?
 
Old 03-16-2010, 06:29 AM   #2
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

Rep: Reputation: Disabled
By using a complete absolute path to the script?
 
Old 03-16-2010, 06:33 AM   #3
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
Quote:
Originally Posted by kickarzt View Post
How to run a bashscript no matter where u stand in the directory?
May be by keeping the script in /usr/bin/ directory, Provided /usr/bin path added in PATH environment variable and you have root privileges.


OR

Add path of the directory where the scripts exists to PATH environment variable

Better set PATH variable in ~/.bash_profile.
Code:
$PATH=$PATH:/usr/bin:/your/directory/where/script/present
export $PATH
Now execute

Code:
source ~/.bash_profile

Last edited by vinaytp; 03-16-2010 at 06:48 AM.
 
Old 03-16-2010, 07:03 AM   #4
kickarzt
LQ Newbie
 
Registered: Feb 2010
Posts: 18

Original Poster
Rep: Reputation: 0
Thank for the answers!
 
Old 03-16-2010, 07:53 AM   #5
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 69
Personally, because playing with $PATH can lead to some behaviour you don't always want, I set subroutines in my .bashrc; colour paging (Which grabbed from some website, forgotten the name, but I dare say the author of this solution wont mind)

Code:
# syntax highlighting pager
colpage () {
/usr/share/vim/vim71/macros/less.sh "$*"
}
 
  


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
LXer: Does Linux stand a chance now that Windows 7 will run on netbooks? LXer Syndicated Linux News 0 01-17-2009 07:50 AM
LXer: Does Linux stand a chance now that Wndows 7 will run on netbooks? LXer Syndicated Linux News 0 01-16-2009 11:10 PM
Using wine to run games, does it matter how I install theme? Nsis Linux - Newbie 11 09-11-2008 06:56 PM
What do the directory names stand for jken Linux - General 4 08-26-2004 08:26 AM
What does the directory /etc/ stand for? nutshell Linux - General 2 03-01-2002 11:41 AM


All times are GMT -5. The time now is 04:43 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