There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Linux and Unix
Tag Cloud
access acer asus bios bsod computer crash driver drivers error ethernet excel freeze gaming google gpu graphics hard drive hardware hdmi internet laptop malware memory monitor motherboard mouse network printer problem ram registry router server slow software sound svchost.exe trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
Executing a program in Unix

Reply  
Thread Tools
Annorax's Avatar
Member with 279 posts.
 
Join Date: Aug 2003
Location: Westfield, MA
Experience: Intermediate
02-Aug-2005, 10:05 PM #1
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
Squashman's Avatar
Trusted Advisor with 18,705 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
02-Aug-2005, 10:30 PM #2
try /usr/games/./gamename
Annorax's Avatar
Member with 279 posts.
 
Join Date: Aug 2003
Location: Westfield, MA
Experience: Intermediate
02-Aug-2005, 10:47 PM #3
Hey that works, thank you. But why doesn't it work when I just type in the name and why does that work?
Squashman's Avatar
Trusted Advisor with 18,705 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
02-Aug-2005, 10:54 PM #4
Same as in Windows. Environmental variable: PATH
Annorax's Avatar
Member with 279 posts.
 
Join Date: Aug 2003
Location: Westfield, MA
Experience: Intermediate
02-Aug-2005, 11:06 PM #5
Also, typing in ./ gamename works too.
Squashman's Avatar
Trusted Advisor with 18,705 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
02-Aug-2005, 11:13 PM #6
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.
Annorax's Avatar
Member with 279 posts.
 
Join Date: Aug 2003
Location: Westfield, MA
Experience: Intermediate
02-Aug-2005, 11:22 PM #7
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...
Squashman's Avatar
Trusted Advisor with 18,705 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
03-Aug-2005, 12:04 AM #8
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.
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
03-Aug-2005, 12:41 AM #9
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.
AGCurry's Avatar
Senior Member with 431 posts.
 
Join Date: Jun 2005
Location: Kansas City area
Experience: advanced but learning
03-Aug-2005, 10: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 at 01:24 PM..
Annorax's Avatar
Member with 279 posts.
 
Join Date: Aug 2003
Location: Westfield, MA
Experience: Intermediate
03-Aug-2005, 07: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.
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
04-Aug-2005, 01:17 AM #12
You're welcome -- glad my comments were helpful.
Reply

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.

Search Tech Support Guy

Find the solution to your
computer problem!




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.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 05:52 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.