Help with distributing scripts


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with distributing scripts
# 1  
Old 04-19-2010
Help with distributing scripts

Hi,

I have written a series of BASH scripts that I have grouped together into a software package I distribute to other users in my field. The package consists of a "master script", which users modify to specify particular processing variables. Depending on the variables specified, and their values, certain sub-scripts are then called to process data files.

As I mentioned, I have made this package of scripts available to download. Many users have limited UNIX experience, and I have tried to make everything as simple as possible. However one problem I have had is how to simplify the "installation" process.

The problem arises from the fact that users will install the folder of scripts in different locations. Therefore references to the master script, and all the subscripts it calls, will likely differ from user to user. For example, to run the master script one User 1 may have to type:
Code:
~/Desktop/example_software/master_script.sh

while User 2 will have to type:
Code:
~/bin/example_software/master_script.sh

And to call the first sub-script User 1's master script will need the line:
Code:
~/Desktop/example_software/subscript_1.sh

while User 2's master script will need:
Code:
~/bin/example_software/master_script.sh

It is obviously impossible to personalize scripts for every user. Does anyone have any suggestions on how to get around this? Is it as simple as telling everyone to install the scripts in their home directory (~)? Would that cause problems?

Thanks for any help,
Mike
# 2  
Old 04-19-2010
You could try calling e.g. subscript_1.sh like this from master_script.sh:
Code:
${0%/*}/subscript_1.sh

# 3  
Old 04-19-2010
Hi Scrutinizer,

Thank you very much for your help.

How can I solve the problem that the master script's location will vary by user?
# 4  
Old 04-19-2010
Hi msb65, Why would that be a problem? Do you mean the users would not understand how to call the master script?
# 5  
Old 04-19-2010
Hi Scrutinizer,

You are right, I should have more faith in my users!

Do you mind explaining how the ${0%/*} syntax works?

Thank you very much.

Mike
# 6  
Old 04-19-2010
Hi msb65,

$0 Expands to the name of the shell script as it was called on the command line. By using parameter expansion ${parameter%word} the smallest suffix pattern is removed. In this case everything after and including the last slash gets removed (/*), i.e. the name of the script itself. What remains is the absolute or relative path to the directory in which the scripts are located...

S.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Distributing script projects, suggestions/ideas?

Heyas If you recall, not too long ago, i was asking about the GNU Autotools. The feedback on that was almost unisense, and me figured that it turned my (back then) +98% SHELL project into a +73% GROFF project... :( Felt a bit overhelmed, specialy since i didnt actualy use or need the true... (0 Replies)
Discussion started by: sea
0 Replies

2. Shell Programming and Scripting

KSH - How to call different scripts from master scripts based on a column in an Oracle table

Dear Members, I have a table REQUESTS in Oracle which has an attribute REQUEST_ACTION. The entries in REQUEST_ACTION are like, ME, MD, ND, NE etc. I would like to create a script which will will call other scripts based on the request action. Can we directly read from the REQUEST_ACTION... (2 Replies)
Discussion started by: Yoodit
2 Replies

3. Shell Programming and Scripting

Distributing a perl script

Hi all, I'm new to the world of Perl so may have gone about this in the wrong way (my background is mainly Java and Bash). I have a Perl script (gallery.pl) which takes in various arguments (the only mandatory arguments is a directory full of images) and creates an HTML, standards compliant... (1 Reply)
Discussion started by: forquare
1 Replies

4. Shell Programming and Scripting

Changing the Bash Scripts to Bourne Scripts:URGENT

Hi, I have to write a program to compute the checksums of files ./script.sh I wrote the program using bash and it took me forever since I am a beginner but it works very well. I'm getting so close to the deadline and I realised today that actually I have to use normal Bourne shell... (3 Replies)
Discussion started by: pgarg1989
3 Replies

5. Shell Programming and Scripting

Running scripts within scripts from cron

Hi all, I have set up a cron job which calls another shell script shell script which in turn calls a Java process. The cron tab looks so. 0,30 7-18 * * 1-5 /u01/home/weblogic/brp/bin/checkstatus.sh >> /u01/home/weblogic/logs/checkstatus.log The checkstatus.sh scripts looks like this. ... (4 Replies)
Discussion started by: sirbrian
4 Replies

6. UNIX for Dummies Questions & Answers

Profile scripts versus rc scripts....

what is the difference between login and profile scripts versus the rc scripts? (1 Reply)
Discussion started by: rookie22
1 Replies

7. Shell Programming and Scripting

Distributing folders into set sizes

Is it possible to have a script watch a folder which contains other folders and split the contents into folders of under 700MB? Not sure if I explained that very well, but I have on my server an 'archive' folder where finished work is dropped, it is then burned to CD for storage and deleted, I... (3 Replies)
Discussion started by: redturbo
3 Replies
Login or Register to Ask a Question