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 |
Code:
$ echo $PATH |
Yes; like I say, the directory it in my PATH. Its actually the first entry
|
However, my shell doesnt start with $
I have <computer name>{<my user name>}<command number>: can it be a shell problem? |
Most users use ~/bin/ for their scripts. Is the executable bit set on the script?
|
Ok, I moved the directory to ~/bin and changed my PATH variable
What is the executable bit, and how do I set it? Thanks |
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 HTH Forrest |
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... |
"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. |
Here it is (I put some hard returns on purpose, not to make the page too wide):
Quote:
|
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. |
What happens if you cd to the directory the script is in and type "./VNC" (The script is in caps?)
Let us know, Forrest |
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.... |
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. |
You say you always
Code:
cd 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 |
All times are GMT -5. The time now is 07:32 AM. |