Automatically determining directory path for scripts and programs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automatically determining directory path for scripts and programs
# 1  
Old 03-22-2012
Automatically determining directory path for scripts and programs

I have some C++ code in the following directory structure

Code:
/home/chrisd/tatsh/trunk/hstmy/
├── baseLib
├── bin
│   ├── awk
│   ├── bash
│   ├── diag
│   ├── ksh
│   │   └── TAG201011
│   ├── old
│   ├── perl
│   ├── prog
│   ├── py
│   └── tcsh
├── docs
├── fortran
├── others
├── scripts
└── source

My directory structure of my data is

Code:
/home/chrisd/tatsh/trunk/hsdata/
├── docs
│   ├── drw-doc
│   └── smp-doc
├── htest1
│   ├── darwin
│   │   ├── jcdint
│   │   ├── npt02
│   │   ├── npt04
│   │   ├── npt06
│   │   ├── npt08
│   │   ├── npt10
│   │   ├── npt20
│   │   ├── npt30
│   │   ├── npt40
│   │   ├── npt50
│   │   ├── test2
│   │   └── Tmp
│   ├── J-Test
│   ├── misfit
│   ├── models
│   ├── pdf
│   ├── raytrac
│   │   ├── A-jcdint
│   │   ├── B-npt02
│   │   ├── C-npt04
│   │   ├── D-npt06
│   │   ├── E-npt08
│   │   ├── F-npt10
│   │   ├── G-npt20
│   │   ├── H-npt30
│   │   ├── I-npt40
│   │   └── J-npt50
│   ├── residuals
│   ├── simplex
│   │   ├── A-jcdint
│   │   ├── B-npt02-smp
│   │   ├── C-npt04-smp
│   │   ├── D-npt06-smp
│   │   ├── E-npt08-smp
│   │   ├── F-npt10-smp
│   │   ├── G-npt20-smp
│   │   ├── H-npt30-smp
│   │   ├── I-npt40-smp
│   │   ├── J-npt50-smp
│   │   └── Tmp
│   └── synt
│       ├── jcdint
│       ├── npt02
│       ├── npt04
│       ├── npt06
│       ├── npt08
│       ├── npt10
│       ├── npt20
│       ├── npt30
│       ├── npt40
│       └── npt50
└── synth
    ├── jcd
    ├── n02
    ├── n06
    ├── n10
    └── n20

Basically I go to one of my data directories
Code:
/home/chrisd/tatsh/trunk/hsdata/htest1/raytrac/A-jcdint

by performing
Code:
cd /home/chrisd/tatsh/trunk/hsdata/htest1/raytrac/A-jcdint

and run the scripts from the data directory using

Code:
/home/chrisd/tatsh/trunk/hstmy/bin/bash/raytrac.bash data1 data2

The thing is that my bash script raytrac.bash needs to call other scripts and programs as well.

For example, from within my bash script, raytrac.bash, I would need to call
Code:
/home/chrisd/tatsh/trunk/hstmy/bin/bash/browseFiles.bash opt1 opt2

awk -v dsrmx=$dsrmx -f /home/chrisd/tatsh/trunk/hstmy/bin/awk/addTrvt.awk $f > $fout

/home/chrisd/tatsh/trunk/hstmy/bin/prog/raytrac --vmod=$cmodInfile --srfile=$srcsInfile

So I am wondering how to automatically set up the paths I need for the bash, awk and prog directories, without having to hardwire the paths. This is important as I can always run my tests on whatever machine I want without having to change the paths every time.

Basically by knowing where my data and my bash script is, the base script will take care of figuring out the directory paths for the bash, awk and prog directories.

How can I best do this in bash?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Determining whether given string is path or not

I have an issue while determing whether given string is unix path or not There is a text file which is normally a report in that at some place we have unix path as shown below /opt/smart/dev/eur/sources/sqr and not unix path as shown below Threshold Year/Month/Ref/ActLine/OUC Is there... (3 Replies)
Discussion started by: lalitpct
3 Replies

2. Shell Programming and Scripting

File maintenance programs/scripts ala logrotate

Hi all, Before I start writing my own file maintenance script, maybe one such program/scripts already exist somewhere :-) Am looking for a file maintenance script/application that is configurable that I can use to process files under certain criteria, for example, removing files that are... (4 Replies)
Discussion started by: newbie_01
4 Replies

3. OS X (Apple)

Right-Click scripts and programs in finder

How can I add a right-click option where I can add my own programs and script to finder? (4 Replies)
Discussion started by: codecaine
4 Replies

4. Shell Programming and Scripting

Automatically execute all programs in a directory

Hello. The last days I extended an open-source C++ library by some faster functions. This library provides a lot of short test programs which guarantee that the library works exactly. The compilation of each test works in a Makefile automatically. What I need is a shell script which... (5 Replies)
Discussion started by: max3000
5 Replies

5. Shell Programming and Scripting

determining actual directory of a symlinked directory

Hello all, I have files at /var/dir1/dir2/fil1.log etc.,. dir2 is symlinked to /export/xxx/dir3 I am trying to monitor the disk space of the mount where these log files are present. How do I determine dynamically the actual directory of the log files and corresponding mount when I use df... (3 Replies)
Discussion started by: chiru_h
3 Replies

6. Shell Programming and Scripting

Determining directory path

Hello, I have a script where I get the full directory path of the script being executed: BASE=$0 echo "BASE:" $BASE The output looks like this: BASE: /webapps/appsdev/ACURA/rlz/oses3.sh I'd like to truncate the shell name, leaving just the directory path. The directory path can be... (2 Replies)
Discussion started by: cwalsek
2 Replies

7. Shell Programming and Scripting

Scripts for calculating size and remaining space of a directory automatically.

I would like to create a script for calculating size and remaining space of a directory automatically every 24 hours, then send an email to report to the admin. * POSIX and PERL are preferred. Can anyone help, please? (1 Reply)
Discussion started by: leonall
1 Replies

8. Answers to Frequently Asked Questions

scripts/programs/code posted to www.unix.com

Every now and then our users post complete programs to this site. It is especially important that these contributions don't get lost, so I will collect them here. Some of these programs are intended to demonstrate a programming technique and some are ready to run. As a guideline, the code... (0 Replies)
Discussion started by: Perderabo
0 Replies

9. Shell Programming and Scripting

Determining absolute PATH within KSH script

Hey everyone, I'd like to determine the absolute path of where a script resides from within the same script. For example, I have a script - /tmp/myscript. Regardless of how that script is call - '/tmp/myscript', 'cd /tmp;./myscript', '. /tmp/myscript' - I'd like to be able to determine - from... (5 Replies)
Discussion started by: gsatch
5 Replies
Login or Register to Ask a Question