Installer script needs to determine own location...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Installer script needs to determine own location...
# 1  
Old 09-20-2008
Question Installer script needs to determine own location...

My n00b question:

I am trying to write a script that I can place on a flash drive and then move from computer to computer and install a file, which is bundled with the script. (ie the script is at /Volumes/FlashDrive/Folder/Script, the file is at /Volumes/FlashDrive/Folder/File)

So far I have figured the
"${0}" will determine the ever-changing location of the script, but how can I use that (or something else, for that matter) to also determine the location of the file to be installed?

So far, I have something like this:
Code:
MYPATH=${0}
cp $MYPATH/file /Applications

With the obvious problem that "$MYPATH" includes the name of the running script after the directory in which it and the file are located.

Any help would be great, thanks!
# 2  
Old 09-22-2008
The dirname command should help you.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

YASSI - Yet Another Simple Script Installer (2020 edition)

Heyas As someone said he'd like to see some more projects posts on the forum, so, here's one I hope is ready. Not so much fun-fun, but practical ;) I hope... So, you have that small non-arch project you would like to install, but get the feeling that GNU Autoconf is a bit too 'massive' for... (2 Replies)
Discussion started by: sea
2 Replies

2. Shell Programming and Scripting

Installer is shell script not working

Hi Guys, I have one installer shell script which normally get from the dev team to install the app and it works fine for years (in IAX) the same installer/script iam trying to run in Linux 7.2 but it stuck somewhere which I cannot debug, can you help me to point out where it stuck . here is the... (9 Replies)
Discussion started by: Riverstone
9 Replies

3. Shell Programming and Scripting

Script to determine server IP

Need help with the script, I am trying to include this script as part of kickstart profile. based of the host's IP address, in this case if the host is IP starting with 10.10.3.* or 10.10.6.*, I will be pushing appropriate routing file from my web server. I validate host IP from nslookup. ... (3 Replies)
Discussion started by: bobby320
3 Replies

4. Shell Programming and Scripting

Yet another simple script installer

Heyas Just recently i tried to apply the GNU Autotools to my project, while it was possible, it took forever to know where to create which files and what to place in each of them. Dare you making a space rather than a tab! Inspired by GNU Autotools, and overhelmed by its functionality and... (0 Replies)
Discussion started by: sea
0 Replies

5. Shell Programming and Scripting

Xfce installer script

Xfce desktop installer script on Ubuntu for home, office or server computers. This script installs Xfce desktop and a set of programs according to user needs starting from an Ubuntu Server base system. It's valid for netbooks, notebooks, desktop computers and servers. For more information... (1 Reply)
Discussion started by: cesar-rgon
1 Replies

6. Shell Programming and Scripting

How to find a existing file location and directory location in Solaris box?

Hi This is my third past and very impressed with previous post replies Hoping the same for below query How to find a existing file location and directory location in solaris box (1 Reply)
Discussion started by: buzzme
1 Replies

7. UNIX for Dummies Questions & Answers

Determine FULL name of current script

Hi everyone, Is there a slick way to determine the FULL name of a script that is running? The variable ${0} just gives the relative path name. I guess I could just do the following: FULL_SCRIPT_NAME=${PWD}${0}Although that's pretty simple is there another way that I am missing? ... (4 Replies)
Discussion started by: msb65
4 Replies

8. Shell Programming and Scripting

Shell Script for Copy files from one location to another location

Create a script that copies files from one specified directory to another specified directory, in the order they were created in the original directory between specified times. Copy the files at a specified interval. (2 Replies)
Discussion started by: allways4u21
2 Replies

9. Shell Programming and Scripting

Installer script -- function not found error

I am writing an installation script on AIX. This involves typical checks of some pre requisites like java, oracle, some version checks, disk space etc. It is a long script. I am facing a strange problem. There are a no of functions used in the script. What I see is that the installer complains of... (1 Reply)
Discussion started by: asutoshch
1 Replies

10. Shell Programming and Scripting

How to determine the script is called from CRON?

Hello expert, What I want is to determine whether the script is called from CRON or it is executed interactively? I tried the following but no luck: #!/bin/ksh cronID=`pgrep -x cron` GPID=`ps -ef -o ppid,pid | grep " $PPID$" | awk '{print $1}'` if ; then echo I am being run... (15 Replies)
Discussion started by: wes_brooks
15 Replies
Login or Register to Ask a Question