Originally Posted by corp769
What you could do is create a script and have it contain a variable to have the absolute path of your choice. Then you can pre-pend the variable to the command and voila. Just my two cents.
I don't understand. Are you talking about an environment variable? And how do you prepend the variable to the command?
Originally Posted by Noway2
Just a thought, but have you looked at using chroot? If so, I am curious as to why it isn't a solution for you. I ask because I am not really up on all the ins-and-outs of how to use it, but it sounds like it does all or at least most of what you want and it looks like you have met the major requirements by having the libraries and binaries self contained. The (free) book Linux From Scratch has a good section on setting up a chroot environment, including the preparatory bindings and creation of a the /proc file system based off of the primary one if you would like to look at a easy to follow example.
That was my first attempt, and after what you have just said I probably should look into it deeper. The problems I have with chroot are these:
- chroot requires root access. (Okay, not a big
- chroot requires the program and all of it's dependencies to be inside
the chroot'ed directory. I only want to redirect all file
operations to a directory, not run it in it's own environment. If I have to modify libc or whatever library handles file operations, I will, but I am looking for a solution that already exists.
- chroot must run the program, as opposed to simply running the program. (For what I am going to use this for, this is a major inconvenience).
- I cannot get it to work.
Running "sudo chroot /media/sda6/bryan/dev/cplib-build-desktop/portable /cplib" gives me this error:
"chroot: cannot run command `/cplib': No such file or directory"
ls "/media/sda6/bryan/dev/cplib-build-desktop/portable" returns:
cplib libdl.so.2 libgthread-2.0.so.0 libpthread.so.0 libstdc++.so.6
ld-linux.so.2 libgcc_s.so.1 libm.so.6 libQtCore.so.4 libz.so.1
libc.so.6 libglib-2.0.so.0 libpcre.so.3 librt.so.1 run-cplib-portably.sh
cplib is configured to search in the directory it is in for libraries (using 'patchelf --set-rpath ./ cplib').
I suspect it is because required system functionality is not duplicated in the new environment. Maybe it requires a shell? Anyway, I don't want to duplicate it (I imagine that this would be inefficient for many programs).
Thanks for the insightful replies!