There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
UNIX/Linux
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > UNIX/Linux >
Executing a program in Unix


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Annorax's Avatar
Senior Member with 275 posts.
 
Join Date: Aug 2003
Location: Westfield, MA
Experience: Intermediate
02-Aug-2005, 09: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
Distinguished Member with 12,589 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
02-Aug-2005, 09:30 PM #2
try /usr/games/./gamename
Annorax's Avatar
Senior Member with 275 posts.
 
Join Date: Aug 2003
Location: Westfield, MA
Experience: Intermediate
02-Aug-2005, 09: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
Distinguished Member with 12,589 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
02-Aug-2005, 09:54 PM #4
Same as in Windows. Environmental variable: PATH
Annorax's Avatar
Senior Member with 275 posts.
 
Join Date: Aug 2003
Location: Westfield, MA
Experience: Intermediate
02-Aug-2005, 10:06 PM #5
Also, typing in ./ gamename works too.
Squashman's Avatar
Distinguished Member with 12,589 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
02-Aug-2005, 10: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.
__________________
I hate asking the same question twice!
How to ask questions the smart way!
Microsoft MVP - Windows Shell/User
Annorax's Avatar
Senior Member with 275 posts.
 
Join Date: Aug 2003
Location: Westfield, MA
Experience: Intermediate
02-Aug-2005, 10: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
Distinguished Member with 12,589 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
02-Aug-2005, 11:04 PM #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
02-Aug-2005, 11:41 PM #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, 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.
Annorax's Avatar
Senior Member with 275 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.
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
04-Aug-2005, 12:17 AM #12
You're welcome -- glad my comments were helpful.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

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 12:22 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.