 | Senior Member with 279 posts. | | Join Date: Aug 2003 Location: Westfield, MA Experience: Intermediate | | Executing a program in Unix I recently got OpenBSD to install on my Vmware. I am trying to run a game from /usr/games but every game I type into the command line I get gamename: not found.
I am a Unix noob so I must be missing something simple here. Anyone know how to do this?
__________________ My Computer:
==========
Windows XP Professional w/SP2 on 300gig HD
AMD Athlon XP 1600 w/512 MB PC133 SDRAM
Hercules Kyro2 w/64 MB RAM
80gig 7200rpm HD & 20gig 5400rpm HD slaves
TDK 40x CD-RW
SoundBlaster Live 5.1 | | Distinguished Member with 14,984 posts. | | Join Date: Apr 2003 Location: 1265 Lombardi Ave Experience: IIAHYAYCESA,YAADA! | | try /usr/games/./gamename | | Senior Member with 279 posts. | | Join Date: Aug 2003 Location: Westfield, MA Experience: Intermediate | | Hey that works, thank you. But why doesn't it work when I just type in the name and why does that work? | | Distinguished Member with 14,984 posts. | | Join Date: Apr 2003 Location: 1265 Lombardi Ave Experience: IIAHYAYCESA,YAADA! | | Same as in Windows. Environmental variable: PATH | | Senior Member with 279 posts. | | Join Date: Aug 2003 Location: Westfield, MA Experience: Intermediate | | Also, typing in ./ gamename works too. | | Distinguished Member with 14,984 posts. | | Join Date: Apr 2003 Location: 1265 Lombardi Ave Experience: IIAHYAYCESA,YAADA! | | Quote: |
Originally Posted by Annorax Also, typing in ./ gamename works too. | Yes, if the file you are executing is in your current working directory, then yes that works as well.
If you dont want to change to the directory or type in the full path name everytime, you can set the PATH variable in your profile file. You could add /usr/games to your path variable so that you can just type the gamename from whatever directory you are in. | | Senior Member with 279 posts. | | Join Date: Aug 2003 Location: Westfield, MA Experience: Intermediate | | But I was in the /usr/games directory when I typed in the game name but it didn't work. Typing in ./ game does. It was pretty strange... | | Distinguished Member with 14,984 posts. | | Join Date: Apr 2003 Location: 1265 Lombardi Ave Experience: IIAHYAYCESA,YAADA! | | PATH is everything. In a nix environment it searches for the command you are executing in the PATH. If it is not in the path it does not execute. | | Senior Member with 1,410 posts. | | | | Quote: |
But I was in the /usr/games directory when I typed in the game name but it didn't work. Typing in ./ game does. It was pretty strange...
| This only means that "." (the current directory) was not in your PATH. By default, "." is not included in root's PATH, since this represents a security hole. So, if you were root and attempted to execute a program (game, whatever) in the current directory, you likely would receive a "not found" message. Also, if you were a normal user, but your PATH did not include ".", you would receive the same message when you tried to execute a program in the current directory. Unlike DOS, Unix/Linux does not automatically search the current directory for files to be executed. When you type "./game" you explicitly specify where the program to be executed is located, which is why it works.
Hope this helps.
__________________ The slowest component still sits at the keyboard. | | Senior Member with 431 posts. | | Join Date: Jun 2005 Location: Kansas City area Experience: advanced but learning |
03-Aug-2005, 09:58 AM
#10 | Quote: |
Originally Posted by codejockey This only means that "." (the current directory) was not in your PATH. By default, "." is not included in root's PATH, since this represents a security hole. | For the superuser, this is true.
For everyone else, it's only a security hole if . is not the LAST path in the PATH. In other words,
export PATH=/bin:/usr/bin:/usr/local/bin:/usr/games:.
is fine, but
export PATH=.:/bin:/usr/bin:/usr/local/bin:/usr/games
is not.
You shouldn't be playing games as root anyway!
Last edited by AGCurry : 03-Aug-2005 12:24 PM.
| | Senior Member with 279 posts. | | Join Date: Aug 2003 Location: Westfield, MA Experience: Intermediate |
03-Aug-2005, 06:40 PM
#11 | Quote: |
Unlike DOS, Unix/Linux does not automatically search the current directory for files to be executed. When you type "./game" you explicitly specify where the program to be executed is located, which is why it works.
| Ah that was my confusion. I've been using DOS for a decade and am used to being in the folder of a program to execute it. Thanks for the clarification. | | Senior Member with 1,410 posts. | | |
04-Aug-2005, 12:17 AM
#12 | You're welcome -- glad my comments were helpful. |  THIS THREAD HAS EXPIRED.
Are you having the same problem?
We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.
|
Smart Search
| Find your solution! | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |  WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
| You Are Using: |
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 05:46 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd. | |
|