The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 04:46 AM
Multiple Paths to SAN with LVM in Linux? deckard Filesystems, Disks and Memory 3 08-10-2007 10:13 AM
create paths alias47 UNIX for Dummies Questions & Answers 4 08-07-2007 09:14 AM
Checking the valid paths in the shell script srivsn Shell Programming and Scripting 3 12-28-2005 12:05 AM
paths caiohn UNIX for Dummies Questions & Answers 1 01-17-2001 07:35 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-03-2008
dowell dowell is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 16
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??
  #2 (permalink)  
Old 03-03-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,294
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
  #3 (permalink)  
Old 03-03-2008
Dave Miller's Avatar
Dave Miller Dave Miller is offline
Registered User
  
 

Join Date: Dec 2007
Location: Northern NJ, USA
Posts: 151
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.
  #4 (permalink)  
Old 03-04-2008
dowell dowell is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 16
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.
  #5 (permalink)  
Old 03-04-2008
dowell dowell is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 16
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.
  #6 (permalink)  
Old 03-04-2008
apsprabhu apsprabhu is offline
Registered User
  
 

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

cd $HOME
ls -lart ---> list the files whose name starts with "." (hidden files)
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:08 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0