-   Linux - Newbie (
-   -   soft link (

puntino 03-28-2012 08:42 AM

soft link
I have a binary file in the folder
I want to create a soft link to "mybinary" in the
folder home/puntino.
In the folder home/puntino I executed the command
ln -s /opt/mybinaryFolder/mybinary mybinary
I get a softlink to mybinary (the code it is hereafter)

scriptdir=`dirname $0`
export LD_LIBRARY_PATH=$scriptdir
$0.bin "$@"

however if I try the command
./mybinary from /home/puntino it doen't work
the first error message was
"./mybinary: line 4: ./mybinary.bin: No such file or directory
I don't have the file mybinary.bin but simple mybinary
so I corrected the last line in the former code
in $0 "$@"
when I execute again the command
./mybinary from home/puntino
it gets stuck.
Thank you in advance.

acid_kewpie 03-28-2012 08:55 AM

of course it gets "stuck" you're creating an infinite loop!

sounds like you just want to NOT create that symlink in the first place. isn't the least confusing way to deal with this all?

suicidaleggroll 03-28-2012 09:52 AM

Are you just trying to set LD_LIBRARY_PATH whenever you call mybinary?
If mybinary never moves from /opt/mybinaryFolder/, then why not just fix LD_LIBRARY_PATH in your shell startup script and then you can call mybinary without issue. Otherwise you'll need two scripts, mybinary_start and mybinary, where mybinary_start sets up LD_LIBRARY_PATH and then calls mybinary. The way you have it now, mybinary is calling itself, over and over and over again. Like acid_kewpie said, you're stuck in an infinite loop.

pan64 03-28-2012 12:41 PM

Oh yes, that is an infinite loop:

$0 "$@"

What is your original goal?

puntino 03-29-2012 05:07 PM

Thank you all.
What I just wanted to do it is to create a shortcut to a binary file
that allowed me to invoke mybinary.
Like in windows, I wanted the shortcut in my home directory
while the binary file is in an opt sub-folder.
I found that a possible way to do that is
using the ln -s command.
Is there any other way to do that ?
Thank you in advance

chrism01 03-29-2012 06:08 PM

I'd say a symlink is indeed what you would use. Optionally, you could use a hardlink, although only a symlink can refer to a target on a different partition

pan64 03-30-2012 03:11 AM

Do you mean this?


scriptdir=`dirname $0`
export LD_LIBRARY_PATH=$scriptdir
/opt/mybinaryFolder/$0 "$@"

You could use symbolic link instead (ln -s)

acid_kewpie 03-30-2012 03:13 AM

why would they mean that?? that's mushing together two different directories into one nonexistent path.

pan64 03-30-2012 03:24 AM


Originally Posted by acid_kewpie (Post 4640412)
why would they mean that?? that's mushing together two different directories into one nonexistent path.

He mentioned a shortcut to a binary, that is something what windows have. a similar thing could have been a little script invoking the real binary.
In unix we can have a symbolic link instead (I wrote instead, both of them together is not ok. But you are right, I mistyped, that should be basename $0)


script=`basename $0`
scriptdir=`dirname $0`
export LD_LIBRARY_PATH=$scriptdir
/opt/mybinaryFolder/$script "$@"

acid_kewpie 03-30-2012 03:31 AM

you'd need to hardcode the path for LD_LIBRARY_PATH too

bett off just having a script like

cd /opt/where/ever

All times are GMT -5. The time now is 05:51 PM.