LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 03-28-2012, 09:42 AM   #1
puntino
Member
 
Registered: Sep 2006
Location: Italy
Distribution: Suse 10.1
Posts: 71

Rep: Reputation: 15
soft link


Hi,
I have a binary file in the folder
/opt/mybinaryFolder/mybinary
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)
Code:
#!/bin/bash
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.
 
Old 03-28-2012, 09:55 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
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?
 
Old 03-28-2012, 10:52 AM   #3
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 3,221

Rep: Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155
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.
 
Old 03-28-2012, 01:41 PM   #4
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,159

Rep: Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364
Oh yes, that is an infinite loop:
Code:
#!/bin/bash
$0 "$@"
What is your original goal?
 
Old 03-29-2012, 06:07 PM   #5
puntino
Member
 
Registered: Sep 2006
Location: Italy
Distribution: Suse 10.1
Posts: 71

Original Poster
Rep: Reputation: 15
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
 
Old 03-29-2012, 07:08 PM   #6
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
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
http://linux.die.net/man/1/ln
 
Old 03-30-2012, 04:11 AM   #7
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,159

Rep: Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364
Do you mean this?

Code:
#!/bin/bash
scriptdir=`dirname $0`
export LD_LIBRARY_PATH=$scriptdir
/opt/mybinaryFolder/$0 "$@"
You could use symbolic link instead (ln -s)
 
Old 03-30-2012, 04:13 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
why would they mean that?? that's mushing together two different directories into one nonexistent path.
 
Old 03-30-2012, 04:24 AM   #9
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,159

Rep: Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364
Quote:
Originally Posted by acid_kewpie View Post
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)

Code:
#!/bin/bash
script=`basename $0`
scriptdir=`dirname $0`
export LD_LIBRARY_PATH=$scriptdir
/opt/mybinaryFolder/$script "$@"
 
Old 03-30-2012, 04:31 AM   #10
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
you'd need to hardcode the path for LD_LIBRARY_PATH too

bett off just having a script like

cd /opt/where/ever
./myscript
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference Between Soft Link & Hard Link rajaniyer123 Solaris / OpenSolaris 16 09-30-2012 04:42 AM
create soft link and hard link in RHEL5 ramadas88 Linux - Server 6 09-15-2010 05:32 AM
about soft link mail2mphani Linux - Newbie 2 03-05-2009 03:20 PM
hard link and soft link varunrapelly Linux - Newbie 9 10-02-2008 08:05 AM
Soft Link and Hard Link Moataz Red Hat 1 04-25-2005 07:30 AM


All times are GMT -5. The time now is 07:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration