symbolic link to an executable file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting symbolic link to an executable file
# 1  
Old 06-19-2010
symbolic link to an executable file

I have a script within my home folder and want to be able to execute it without using the sh command.

I know that if it was in ~/bin and executable I could do it just by typing the file name, but would rather keep it in the current file structure

I tried creating a soft link in ~/bin, thinking I could then use the name of the link to execute it but I'm still getting the error message "-bash: <linkname>: command not found"

What am I doing wrong?
# 2  
Old 06-19-2010
There seems to be several issues:
1. does your script have a shebang at the top:
Code:
#!/bin/sh

2. is your script executable - i.e., did you run chmod +x myscript.sh

3. You need to add your home directory to your PATH variable, edit your .profile file
add this line.
Code:
export PATH=${PATH}:/home/jaloopa


You do not need a symbolic link to bin
# 3  
Old 06-19-2010
1) yes it does
2) yes it is
3) my system doesn't save exported variables on logout, so I'd have to do this every time I logged in or add the code to the script. Surely there's a tidier way than that?
# 4  
Old 06-19-2010
Quote:
Originally Posted by Jaloopa
1) yes it does
2) yes it is
3) my system doesn't save exported variables on logout, so I'd have to do this every time I logged in or add the code to the script. Surely there's a tidier way than that?
To point 3: If you set the PATH in your .profile as suggested, you wouldn't have to do anything when you log back in.

As to points 1 and 2: It's not sh you need to use to run the script, but the path to the script, which could be remedied as described in point 3.
# 5  
Old 06-19-2010
Ah, gotcha. Somehow managed to miss that bit about editing the file. Thank you both, it works now.

(I think I've been using vi too much. Just went to press esc then :x to save and exit this response)
# 6  
Old 06-19-2010
Quote:
Originally Posted by Jaloopa
Ah, gotcha. Somehow managed to miss that bit about editing the file. Thank you both, it works now.
Great Smilie

Quote:
Originally Posted by Jaloopa
I think I've been using vi too much
You can never use vi too much Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Tomcat 6.0 fails to read symlink(symbolic link) file

Hello all experts, Im in a situation where Tomcat simply does not want to read this file through the symlink.... I checked permissions..OK Also checked file & tomcat owner...all OK. This is what I have my /tomcat/conf/Catalina/local/appname.xml <Context> <Resource name="jdbc/black" ... (3 Replies)
Discussion started by: KingaKoopa
3 Replies

2. UNIX for Dummies Questions & Answers

[Solved] Symbolic link not allowed or link target not accessible

Hi everybody, I read about treads realted to this issue but they did not resovle issue given below. Please help me resolve issue given below I have html file under /srv/www/htdocs/actual_folder ls actual_folder/ test.html and following link works... (0 Replies)
Discussion started by: newbielgn
0 Replies

3. Shell Programming and Scripting

ls on a symbolic link

Hi all, Can anyone please confirm if the command below is the only way that I can get what the symbolic link is set to? mnlxd110(oracle)/db/posd2/dba$: ls -l | grep "^l" lrwxrwxrwx 1 oracle dba 28 Aug 9 2011 bdump -> diag/rdbms/posp1/posp1/trace mnlxd110(oracle)/db/posd2/dba$:... (7 Replies)
Discussion started by: newbie_01
7 Replies

4. Shell Programming and Scripting

Symbolic link to an empty file shows size 2

Hi, I have created an empty file and a symbolic link to a file. But when I issue the following commands, I am getting the output 2. stat -c "%s" linkfile du -hb linkfile Why this is happening? (4 Replies)
Discussion started by: royalibrahim
4 Replies

5. Shell Programming and Scripting

Symbolic Link Help

Hello All, This may be a silly question to some but I am really stuck. Is there a way to reverse the following; sudo rm /bin/sh sudo ln -s /bin/bash /bin/sh It was part of a driver compile/installation procedure by Digi for Ubuntu stating that dash isn't supported and a symbolic link... (2 Replies)
Discussion started by: LAVco
2 Replies

6. Shell Programming and Scripting

symbolic link

Hi, i am trying to create sym links on sles 11 , but it seems i am doing something wrong. oracle@tests:/u01/app/oracle/oradata/ACIS> pwd /u01/app/oracle/oradata/ACIS oracle@tests:/u01/app/oracle/oradata/ACIS> ln -s /db/ACIS/dbase/dbf/ /u01/app/oracle/oradata/ACIS/... (2 Replies)
Discussion started by: tonijel
2 Replies

7. UNIX for Dummies Questions & Answers

How to find .dat file in symbolic link

Hi, I am trying to find all files in a directory that have .dat and .int extensions and removing them. rm -f `find ${MY_DIR} -type f -name '*.dat' -o -name '*.int'` This works fine if $MY_DIR is a regular directory. However when $MY_DIR is a symbolic link then this command fails. How... (1 Reply)
Discussion started by: neeto
1 Replies

8. UNIX for Dummies Questions & Answers

need some info about symbolic link and hard link

hello folks how y'all doin well i have some questions about symbolic link and hard link hope some one answer me i open terminal and join as root and i wrote ln -s blah blah then i wrote ls i see red file called blah blah but didn't understand what is this can some one explain and... (2 Replies)
Discussion started by: detective linux
2 Replies

9. UNIX for Dummies Questions & Answers

symbolic Link

question abt symbolic link ... i'm doing the following ... ln -s x.sh ./scripts/y.sh and cat ./scripts/y.sh it is giving following error cat: cannot open y.sh Any reason u an think of ? But it is working fine when i goto scripts directory and cretae the symbolic link. ... (1 Reply)
Discussion started by: bhargav
1 Replies

10. UNIX for Dummies Questions & Answers

get symbolic link file

hi all, I am trying to ftp and get some symbolic link file as it is instead of getting whatever it is pointing at. Is it do-able? Thx in advance. (11 Replies)
Discussion started by: andrec
11 Replies
Login or Register to Ask a Question