LinuxQuestions.org
Help answer threads with 0 replies.
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 12-17-2007, 02:53 PM   #1
hugene
LQ Newbie
 
Registered: Dec 2007
Posts: 19

Rep: Reputation: 0
how to add my scripts to the path


Hello

I don't have root or sudo.

I create a one liner launch script, I want to add it to my path so that I can call it from anywhere.

Here is the script:

#!/bin/sh
vncviewer <...>

its in a file:

~/MyScripts/bin/VNC

I added the directory ~/MyScripts/bin to my PATH variable.

Now, if I type VNC, the script does not get found! Why is that?

Thank you very much
 
Old 12-17-2007, 02:59 PM   #2
bsdunix
Senior Member
 
Registered: May 2006
Distribution: BeOS, BSD, Caldera, CTOS, Debian, LFS, Mac, Mandrake, Red Hat, Slackware, Solaris, SuSE
Posts: 1,761

Rep: Reputation: 80
Code:
$ echo $PATH
Does the output include /home/<your_username_here>/MyScripts/bin? It is case sentive.
 
Old 12-17-2007, 03:03 PM   #3
hugene
LQ Newbie
 
Registered: Dec 2007
Posts: 19

Original Poster
Rep: Reputation: 0
Yes; like I say, the directory it in my PATH. Its actually the first entry
 
Old 12-17-2007, 03:06 PM   #4
hugene
LQ Newbie
 
Registered: Dec 2007
Posts: 19

Original Poster
Rep: Reputation: 0
However, my shell doesnt start with $

I have

<computer name>{<my user name>}<command number>:

can it be a shell problem?
 
Old 12-17-2007, 03:21 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Most users use ~/bin/ for their scripts. Is the executable bit set on the script?
 
Old 12-17-2007, 03:43 PM   #6
hugene
LQ Newbie
 
Registered: Dec 2007
Posts: 19

Original Poster
Rep: Reputation: 0
Ok, I moved the directory to ~/bin and changed my PATH variable

What is the executable bit, and how do I set it?

Thanks

Last edited by hugene; 12-17-2007 at 03:45 PM.
 
Old 12-17-2007, 03:58 PM   #7
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
The executable bit is a part of the filesystem that tells the system that the file can be executed (or run). There are also bits for reading and writing. These bits can be turned for any combination of the owner of the file (u for user), the group that owns the file (g) and others (o).

Code:
chmod u+x ~/bin/scriptname
will turn on the bit for user (or owner). You can also set the bits for all three at once by leaving off the u.

HTH

Forrest

Last edited by forrestt; 12-17-2007 at 04:02 PM.
 
Old 12-18-2007, 11:42 AM   #8
hugene
LQ Newbie
 
Registered: Dec 2007
Posts: 19

Original Poster
Rep: Reputation: 0
I tried it, and it makes no difference, I still cannot call my script from another location.

There is a star at the end of the file name, I don't know what that means...
 
Old 12-18-2007, 01:02 PM   #9
rsashok
Member
 
Registered: Nov 2006
Location: USA, CA
Distribution: RedHat, Debian
Posts: 202

Rep: Reputation: 31
"star" at the end means that you script is executable, e.g. has 'x' in its attribute. Could you post exact output of:
echo $PATH
BTW: your shell prompt configuration doesn't really matter on the output of shell commands.
 
Old 12-19-2007, 10:15 AM   #10
hugene
LQ Newbie
 
Registered: Dec 2007
Posts: 19

Original Poster
Rep: Reputation: 0
Here it is (I put some hard returns on purpose, not to make the page too wide):

Quote:
<CPU NAME>{<USER_NAME>}86: echo $PATH
/home/<USER_NAME>/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/var/lib/dosemu:
/usr/games:/opt/bin:/opt/gnome/bin:/opt/kde3/bin:/opt/kde2/bin:/opt/kde/bin:/usr/openwin/bin:
/opt/cross/bin:/usr/bin/X11:/usr/lib/mit/bin:/usr/lib/mit/sbin:/pub/linux/noarch/bin:/pub/linux/i386/nodist/java/bin:/opt/rational/clearcase/bin:/opt/novell/iprint/bin:/usr/lib/qt3/bin
<CPU NAME>{<USER_NAME>}87:
 
Old 12-19-2007, 11:36 AM   #11
rsashok
Member
 
Registered: Nov 2006
Location: USA, CA
Distribution: RedHat, Debian
Posts: 202

Rep: Reputation: 31
Path looks good: directory "/home/<USER_NAME>/bin" is there. Make sure that your script is in this directory.
'cd' to any other directory and do "ls /home/<USER_NAME>/bin", and you must see you script in the list. If this
is the case you should be able to execute the script from any location.
 
Old 12-19-2007, 11:46 AM   #12
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
What happens if you cd to the directory the script is in and type "./VNC" (The script is in caps?)

Let us know,

Forrest
 
Old 12-19-2007, 05:03 PM   #13
hugene
LQ Newbie
 
Registered: Dec 2007
Posts: 19

Original Poster
Rep: Reputation: 0
I do see the file when I do ll /home/<USER_NAME>/bin.

As for the second question, this is how I have been running the script till now: just cd to that directory and execute ./VNC

It's a total mystery to me....
 
Old 12-19-2007, 08:08 PM   #14
rsashok
Member
 
Registered: Nov 2006
Location: USA, CA
Distribution: RedHat, Debian
Posts: 202

Rep: Reputation: 31
That is really strange! For the sake of the experiment, try to move your '/home/USER_NAME/bin' at the end of the path.
You could do it by manipulating PATH variable in your .bashrc and .bash_profile in home directory.
 
Old 12-20-2007, 02:47 AM   #15
LinuxCrayon
Member
 
Registered: Nov 2007
Location: Georgia, USA
Distribution: FreeBSD
Posts: 274

Rep: Reputation: 31
You say you always
Code:
cd
to the directory and execute from the directory. Can you execute it while in another directory? That is, can you type
Code:
/home/$username/bin/VNC
?

If you can, and although this is a ridiculous hack, you could try creating an alias...

Again, that's a ridiculous hack to make it work, and you would have to create an alias for every script / program you write...but it should work.

If you can't execute the script by typing
Code:
/home/$username/bin/VNC
, then I'm really stumped...

Last edited by LinuxCrayon; 12-20-2007 at 02:48 AM. Reason: Wrong syntax for tags. I fail.
 
  


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
Do you add to the path line or make a new path in /etc/profile? M$ISBS Linux - Newbie 2 12-13-2006 03:14 PM
creating a new path for scripts Freestone Linux - Newbie 1 10-05-2006 08:30 PM
Linux is bizarre--path informations of scripts apachedude Linux - Software 3 12-31-2005 02:49 AM
scripts can't find path corbis_demon Linux - General 2 09-08-2004 07:11 PM
put my scripts to PATH Boby Linux - Newbie 1 06-14-2004 01:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:40 AM.

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
Open Source Consulting | Domain Registration