please explain these commands to me.
thanks for the time. this is rather simple question i hope:
the commands to execute a program are from the CLI to type in the full path, navigate to the path then type in the name, or use './' to activate the command from were ever you are? is that correct? if so, this is were im confused. last night i was trying to activate something bby first typing in the full path. this was just so i could practice my path skills for the *nix dir. tree. that gave me an error something abot this is not a dir or a program. next i navigate to the dir cd /home/ray..... and type in the program name. same error as above. last i try the ./ program name as i was already in that dir. this worked, but why did this work, and the other 2 ways not? please fill me in on how these things work so i will know the why and not just the how. again, thank you for your time and efforts. |
What is the name of the program you were trying to execute? What is the file name? Is the file set to be (or needs to be set to be) executable?
|
Say you are in /home/ray. You want to execute program 'foo'. As a regular user, you should be able to do it in one of these ways:
/home/ray/foo ./foo foo As root, the last way is disabled for security. |
It all has to do with the current paths setup in your profile and the execution attribute of the file itself.
Is the file executable? $ ls -l /home/ray If the output of the above command starts with rwxrwxrwx, where the x is significant then the file is executable. 'man chmod' is worth reading. the command 'echo $PATH' shows you the current search paths. '.:' or current directory is not normally included, thus the './' is required when you in the right directory. /home/ray/foo will allway work if you have the right permissions (rwx...stuff). ./foo only works when your in that directory. To change your search paths look at 'cat ~/.bash_profile' or 'man profile' hope that helps |
Usually, when you just type in a command like "ls" or the name of a program, bash will look in certain folders (or paths, if you will) like /usr/bin for that command executable. Your home folder isn't usually one of those paths by default, so bash won't be able to find it if it's there, but you can add /home/[your username] to the paths that gets searched. The "./" prefix tells bash explicitly that you want to execute a file that's in your present working directory, so that's why that'll usually work, assuming you have permission to execute the file in question.
|
it was for the TeamSpeak client software.
/home/ray/TeamSpeak_client/TeamSpeak.sh is the full path. the ls -l shows it to be set to rwx for owner, me, and rx for others and group. from what i know that is 755 yes? so trying full path, and navigating to the dir then the filename still gave me errors, yet the ./filename worked perfectly. i am just trying to learn the hows and whys of the linux file tree and command structor for exe. files. i can get it to run that is not the issue here. i just dont understand why the full path and or navigating to the dir. would not run the program yet the last option did. |
Run 'echo $PATH'. If '.' isn't on the list, then just typing the file w/o the './' won't work. As for why the full path is not working, I can only guess that you are typing the path wrong. What error did you get?
|
ok, ill run echo $PATH when i get home. the error is something about not a file or directory.
|
The error message may not be from the command you typed directly. Something in 'TeamSpeak.sh' may be looking for files in the current directory. If your not in the correct directory when you issue the command, the commands fails because it can't find a particular directory or file. The resulting error message looks like its was your commmand, when it truely was not. You made it past step one (execute the command), now step two fails because you are not in the right directory.
You could look through the TeamSpeak.sh script by typing this command ' less TeamSpeak.sh' and using the up/down arrow keys to see the steps it takes. |
ok less is new to me, what is that? i know about vi and gedit, but never heard of less.
i will try that too when i get home this afternoon. |
'less' lets you view the file only, unlike text-editors which let you edit.
|
Code:
[ray@raylap ray]$ cd /home/ray/TeamSpeak2RC2/ [ray@raylap TeamSpeak2RC2]$ ls clicense.txt libborqt-6.9-qt2.3.so manual TeamSpeak client_sdk libHVDI.so.0.8.0 Readme.txt TeamSpeak.bin icon.xpm libspeex.so.1.0.0 sounds [ray@raylap TeamSpeak2RC2]$ ls -l total 9412 -rwxr--r-- 1 ray ray 1328 Dec 7 2002 clicense.txt drwxrwxr-x 2 ray ray 4096 Apr 2 02:12 client_sdk -rw-r--r-- 1 ray ray 6348 Jan 13 2003 icon.xpm -rwxr-xr-x 1 ray ray 7526184 Nov 9 2002 libborqt-6.9-qt2.3.so -rwxr-xr-x 1 ray ray 180344 Feb 18 2003 libHVDI.so.0.8.0 -rwxr-xr-x 1 ray ray 224296 Apr 17 2003 libspeex.so.1.0.0 drwxrwxr-x 2 ray ray 4096 Apr 2 02:12 manual -rwxr--r-- 1 ray ray 3645 Aug 29 2003 Readme.txt drwxrwxr-x 2 ray ray 4096 Apr 2 02:12 sounds -rwxr-xr-x 1 ray ray 216 Jan 13 2003 TeamSpeak -rwxr-xr-x 1 ray ray 1641148 Aug 29 2003 TeamSpeak.bin [ray@raylap TeamSpeak2RC2]$ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/ray/bin [ray@raylap TeamSpeak2RC2]$ echo $PATH /home/ray/TeamSpeak2RC2 /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/ray/bin /home/ray/TeamSpeak2RC2 |
ok ignore that last post.
[ray@raylap ray]$ cd /home/ray/TeamSpeak2RC2/ [ray@raylap TeamSpeak2RC2]$ ls clicense.txt libborqt-6.9-qt2.3.so manual TeamSpeak client_sdk libHVDI.so.0.8.0 Readme.txt TeamSpeak.bin icon.xpm libspeex.so.1.0.0 sounds [ray@raylap TeamSpeak2RC2]$ ls -l total 9412 -rwxr--r-- 1 ray ray 1328 Dec 7 2002 clicense.txt drwxrwxr-x 2 ray ray 4096 Apr 2 02:12 client_sdk -rw-r--r-- 1 ray ray 6348 Jan 13 2003 icon.xpm -rwxr-xr-x 1 ray ray 7526184 Nov 9 2002 libborqt-6.9-qt2.3.so -rwxr-xr-x 1 ray ray 180344 Feb 18 2003 libHVDI.so.0.8.0 -rwxr-xr-x 1 ray ray 224296 Apr 17 2003 libspeex.so.1.0.0 drwxrwxr-x 2 ray ray 4096 Apr 2 02:12 manual -rwxr--r-- 1 ray ray 3645 Aug 29 2003 Readme.txt drwxrwxr-x 2 ray ray 4096 Apr 2 02:12 sounds -rwxr-xr-x 1 ray ray 216 Jan 13 2003 TeamSpeak -rwxr-xr-x 1 ray ray 1641148 Aug 29 2003 TeamSpeak.bin [ray@raylap TeamSpeak2RC2]$ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/ray/bin [ray@raylap TeamSpeak2RC2]$ echo $PATH /home/ray/TeamSpeak2RC2 /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/ray/bin /home/ray/TeamSpeak2RC2 so no '.' when i echo or ls -l so that explains why i could not do some of the commands. thank you for the education on things. learning more and more every day. |
The lack of a '.' shows why just typing the program only doesn't work. However, typing the whole path should work. Post the exact output of the 'pwd' command here.
|
[ray@raylap ray]$ cd /home/ray/TeamSpeak2RC2/
[ray@raylap TeamSpeak2RC2]$ pwd /home/ray/TeamSpeak2RC2 [ray@raylap TeamSpeak2RC2]$ that? |
All times are GMT -5. The time now is 08:33 AM. |