Enabling a script to run in multiple paths


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Enabling a script to run in multiple paths
# 1  
Old 03-03-2008
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  
Old 03-03-2008
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  
Old 03-03-2008
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  
Old 03-04-2008
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  
Old 03-04-2008
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  
Old 03-04-2008
the . profile file usually resides in user home directory.

cd $HOME
ls -lart ---> list the files whose name starts with "." (hidden files)
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Run script on multiple files

Hi Guys, I've been having a look around to try and understand how i can do the below however havent come across anything that will work. Basically I have a parser script that I need to run across all files in a certain directory, I can do this one my by one on comand line however I... (1 Reply)
Discussion started by: mutley2202
1 Replies

2. Shell Programming and Scripting

Wget from multiple paths

if I have these wildcards to download from: path1/*.txt path2/*.txt path3/*.txt path4/*.txt path5/*.txt under a link such as this: http://abc .com/]abc.com Can wget be written in such a way to extract only those files and create the corresponding paths under a target folder? So the... (4 Replies)
Discussion started by: Devyn
4 Replies

3. Shell Programming and Scripting

Run script on multiple files

I have a script that I need to run on one file at a time. Unfortunately using for i in F* or cat F* is not possible. When I run the script using that, it jumbles the files and they are out of order. Here is the script: gawk '{count++; keyword = $1} END { for (k in count) {if (count == 2)... (18 Replies)
Discussion started by: newbie2010
18 Replies

4. Shell Programming and Scripting

Storing multiple file paths in a variable

I am working on a script for Mac OS X that, among many other things, gets a list of all the installed Applications. I am pulling the list from the system_profiler command and formatting it using grep and awk. The problem is that I want to be able to use each result individually later in the script.... (3 Replies)
Discussion started by: cranfordio
3 Replies

5. Shell Programming and Scripting

Script to delete files older than x days and also taking an input for multiple paths

Hi , I am a newbie!!! I want to develop a script for deleting files older than x days from multiple paths. Now I could reach upto this piece of code which deletes files older than x days from a particular path. How do I enhance it to have an input from a .txt file or a .dat file? For eg:... (12 Replies)
Discussion started by: jhilmil
12 Replies

6. Shell Programming and Scripting

Replace directory paths in multiple files at once

I need to update about 2400 files in a directory subtree, with a new directory path inside the files I need to change this occurence in all files: /d2/R12AB/VIS/apps/tech_st/10.1.2 with this: /u01/PROD/apps/apps_st/10.1.3 I know how to change single words using "find . -type f -print0 |... (6 Replies)
Discussion started by: wicus
6 Replies

7. Shell Programming and Scripting

Script to run php script on multiple website domains

Good Day, I have multiple websites on a domain. I am looking for a loop structure that can run each site script. egdomain1/test.php domainx/test.php so on, currently I copy and paste a list of commands but that skips certain commands. Some help would be greatly appreciated. Sergio (3 Replies)
Discussion started by: SergioP
3 Replies

8. Shell Programming and Scripting

find multiple paths

How do i find files in more than one directory? I searched through forums, but could not land into the right thread. I tried something like find dir1|dir2 -name file1 but it doesn't work. Please suggest. (5 Replies)
Discussion started by: krishmaths
5 Replies

9. Filesystems, Disks and Memory

Multiple Paths to SAN with LVM in Linux?

I'm setting up a CentOS 5 server that will be connected to an HP EVA4000. My previous experience is with an HP VA7400 and HP-UX. In HP-UX I can add "alternate paths" to a volume group in order to have redundant paths to the SAN via dual fiber channel HBAs just by either adding them with... (3 Replies)
Discussion started by: deckard
3 Replies
Login or Register to Ask a Question