[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Installing and locating scripts
- From: Steve Litt <slitt@...>
- Date: Mon, 4 Mar 2013 16:56:24 -0500
On Sun, 3 Mar 2013 17:36:17 -0500
Rena <hyperhacker@gmail.com> wrote:
> So, I've been developing some small applications in Lua, and one issue
> that's come to light is once my app is installed, if it's made up of
> more than one script, the main 'executable' script needs to know where
> to find the other scripts.
> It's enough to use os.getenv('PWD') .. arg[0] during testing, but that
> won't work if the script is in the $PATH. Unfortunately my
> understanding is there's no standard way to determine the current path
> of the executable.
>
> I'm also not sure what is the best practice when it comes to
> installing a program that consists of several files (the main
> executable and several sub-scripts it includes) on a Linux system.
Hi Rena,
What I'm going to talk about won't be very popular, and it's neither
Unixly-correct nor Windowsly-correct, but I see a couple people have
already suggested it.
Having computed in the DOS era, I'm a big fan of the "everything in one
tree" paradigm. An install is just an tar xzvf, and an uninstall is just
rm -rf. Your app needs to know about few other facilities, and other
facilities needn't know anything about your app.
The easiest way I've found to do this is, if your app is myapp.lua, put
it in an arbitrary directory along with the other files (or the other
files can be in subdirectories), and then in the same directory put
myapp.sh, whose first few lines look like this:
=====================
#!/bin/bash
cd /whatever/myapp
export ENVARG1=WHATEVER1
export ENVARG2=WHATEVER2
./myapp.lua $1 $2 $3 $4 $5 $6 $7
=====================
The last task is to, within /usr/local/bin or wherever on the path, put
a symlink to myapp.sh.
If you want your app to truly be standalone, this is an effective way
to do it.
SteveT
Steve Litt * http://www.troubleshooters.com/
Troubleshooting Training * Human Performance