The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to add new paths to $PATH wrapster SUN Solaris 2 06-01-2008 01:46 AM
Multiple Paths to SAN with LVM in Linux? deckard Filesystems, Disks and Memory 3 08-10-2007 07:13 AM
create paths alias47 UNIX for Dummies Questions & Answers 4 08-07-2007 06:14 AM
Checking the valid paths in the shell script srivsn Shell Programming and Scripting 3 12-27-2005 08:05 PM
paths caiohn UNIX for Dummies Questions & Answers 1 01-17-2001 03:35 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-03-2008
Registered User
 

Join Date: Nov 2007
Posts: 15
Enabling a script to run in multiple paths

I have a script that i need to run from different paths.

for example
mypc/path1/path2/,
mypc/path1/path2/path3/, and
mypc/path1/path2/path3/path4

How do i set up that script so that it can execute in any
of the above paths or how can i make it run on any path on my computer??
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-03-2008
Moderator
 

Join Date: Feb 2007
Posts: 1,996
Some possibilities:

- make an alias in your .profile
- place the script in a directory that's set in the PATH variable
- add the path of your script in the PATH variable

Regards
Reply With Quote
  #3 (permalink)  
Old 03-03-2008
Dave Miller's Avatar
Registered User
 

Join Date: Dec 2007
Location: Northern NJ, USA
Posts: 149
To elaborate, there is a line in your .profile that says PATH=

The PATH defined has several paths listed, separated by colons. One of the PATHs is probably . by itself. A . by itself means 'current directory'.

When you attempt to execute a command/script, the OS searches each of the paths listed in PATH to find the command/script you specified.

Therefore, you have to put your script in one of the paths specified, or add the path where your script lives to the PATH variable.


On a side note, the command which [command] returns the path of the [command] specified.
Reply With Quote
  #4 (permalink)  
Old 03-03-2008
Registered User
 

Join Date: Nov 2007
Posts: 15
Thanx for the help but am a bit new in unix. Where do i find
that file for the user profiles that i need to edit the PATH variable.
Reply With Quote
  #5 (permalink)  
Old 03-03-2008
Registered User
 

Join Date: Nov 2007
Posts: 15
Thanx for the help but am a bit new in unix. Where do i find
that file for the user profiles that i need to edit the PATH variable.
Reply With Quote
  #6 (permalink)  
Old 03-03-2008
Registered User
 

Join Date: Feb 2008
Posts: 21
the . profile file usually resides in user home directory.

cd $HOME
ls -lart ---> list the files whose name starts with "." (hidden files)
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:18 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0