advertisement
advertisement

Any Linux gurus on this board? [Archive] - MousePad

View Full Version : Any Linux gurus on this board?


hbquikcomjamesl
03-18-2005, 09:13 PM
Anybody know how to set the command path in Linux? I just installed a Linux version of the old mainframe ZORK (aka DUNGEON), and while I could get it to work, I had to (1) open a terminal window to do it, and (2) type the whole pathname from root to filename (i.e., "/home/jamesl/zork/dungeon"), in order to get the thing to launch. Even though I'd already set the current directory to "/home/jamesl/zork" when I tried to launch it.

Best of all would be if there were a way to make it launchable from the GNOME desktop.

You should be able to email me from my MousePad profile.

mrcoffee
03-19-2005, 11:59 AM
I'm not a GNOME dude, so I'm not sure of how to add it to your desktop (but I'm sure it's pretty simple).. But to run a program in your current directory, just type:

./{program}

or in your case

./dungeon while you're in that directory.

Bill Catherall
03-21-2005, 01:20 PM
Anybody know how to set the command path in Linux?
The default command path is set by the PATH environment variable and is usually /usr/bin or just /bin (which is usually just pointing to /usr/bin). You can change PATH within a shell, but this would cause problems with other commands like ls, etc. You could create a unique environment variable that points to the path you want. For example:

setenv ZORK /home/jamesl/zork

(note: linux is case sensitive ZORK is not the same as zork)

When you want to run dungeon just type

$ZORK/dungeon

Unfortunately, this may actually cause more work, once you exit the shell the environment variable will be cleared.

You can make it permanent by adding it to the .cshrc file. Just append the "setenv" line to that file.

Or, the HOME environment variable may already be set to /home/jamesl so you could use that built-in variable to shortcut it as:

$HOME/zork/dungeon

Best of all would be if there were a way to make it launchable from the GNOME desktop.
This is really the best option. Just open a browser window and navigate to your /home/jamesl/zork directory. Right-click on the dungeon icon and select Make Link. This will create a symbolic link (similar to an Alias (Macintosh) or Shortcut (Windows)). Move the symbolic link to the desktop.

I think, but I'm not sure, you could also move (or copy) this symbolic link to the /bin (or /usr/bin) directory and you can run it from a command line without having to specify the path. But I'm not absolutely certain on that one. I haven't tried it before.

mrcoffee
03-21-2005, 05:34 PM
The default command path is set by the PATH environment variable and is usually /usr/bin or just /bin (which is usually just pointing to /usr/bin). You can change PATH within a shell, but this would cause problems with other commands like ls, etc. You could create a unique environment variable that points to the path you want. For example:

setenv ZORK /home/jamesl/zork

(note: linux is case sensitive ZORK is not the same as zork)

When you want to run dungeon just type

$ZORK/dungeon

{SNIP!}

I don't think I would go that far, but if running it from the command line, just add an aias..

alias zork=/home/jamesl/zork/dungeon

Of course, running it from Gnome is the best, but that's what makes UNIX so nice.. so many options.

hbquikcomjamesl
03-21-2005, 11:18 PM
This is really the best option. Just open a browser window and navigate to your /home/jamesl/zork directory. Right-click on the dungeon icon and select Make Link. This will create a symbolic link (similar to an Alias (Macintosh) or Shortcut (Windows)). Move the symbolic link to the desktop.Actually, this accomplishes exactly the same thing as double-clicking directly on the program itself (which would have been perfectly fine with me): absolutely nothing.

In a perfect world, a program that required a terminal window to run would open up a terminal window and start running. Unfortunately, this is not a perfect world.

Setting an alias launches the program, but unless I manually change the current directory to zork, all I get is:
I can't open dindx.dat.
Suddenly a sinister, wraithlike figure appears before you,
seeming to float in the air. In a low, sorrowful voice he says,
"Alas, the very nature of the world has changed, and the dungeon
cannot be found. All must now pass away." Raising his oaken staff
in farewell, he fades into the spreading darkness. In his place
appears a tastefully lettered sign reading:

INITIALIZATION FAILURE

The darkness becomes all encompassing, and your vision fails.

So clearly, I need to come up with something persistent, that will set the current directory appropriately, then launch the program. And if it opens up a terminal window if double-clicked, so much the better.

Of course, running it from Gnome is the best, but that's what makes UNIX so nice.. so many options.I dunno. I think I like OS/400 a lot better in that regard.

hbquikcomjamesl
03-21-2005, 11:59 PM
More:

I found a script tutorial, and was able to figure out enough to write a simple shell script:
cd /home/jamesl/zork
/home/jamesl/zork/dungeon

Double-clicking on that gets me a dialog asking whether I want to run it in a terminal, or display it, or whatever. When I click "run in terminal," it works. But bypassing the dialog would be nice. Is there a way?

Typing the name of the script from the command line launches it if I give it a fully-qualified pathname, or if I qualify it with "./" and it's in the current directory. Otherwise, it gets me the same result I get from typing the program name directly, namely a "not found" message. Setting the "path" environment variable has no effect. Setting an alias to point to my script works.

hbquikcomjamesl
03-22-2005, 12:30 AM
MORE:

I just discovered that I was trying to examine and set the "path" environment variable, when I should have been trying to examine and set the "PATH" environment variable instead. Damned case-sensitivity. It's a pain in the <Eeyore's species> in C, it's a pain in <Eeyore's species> in Java, and it's a pain in <Eeyore's species> in UNIX, Linux, Xenix, Aix, and so forth.

But where do I need to put that, in order to make it persistent? (I'm guessing some startup script, but where?) And what can I do that will smoothly launch Zork in a "Gnome-terminal" window (maybe even with a custom profile, to give a custom title-bar and a custom color scheme), when the appropriate icon is double-clicked, without that annoying "what do you want to do with this script" dialog?

Incidentally, I have a bunch of custom icons I'll gladly provide to anybody who can help me relieve my ignorance.

hbquikcomjamesl
03-22-2005, 01:43 AM
It's almost 1:30 AM, and I finally got it working in a reasonably smooth way. It's a bit kludgy, given that it uses one shell script calling another, and a Gnome Terminal profile, and a change to the Bash profile, but it works.

Firstly, I found the Bash profile, and set it to always include the current directory in my path.

Secondly, the script that actually launches Zork (called "zork") is in the "zork" directory, and is as follows:#!
cd /home/jamesl/zork
dungeon
Third, the calling script, which I've placed on the desktop (under the name "Original Mainframe ZORK"), but it could be anywhere, and called anything, is as follows:#!
gnome-terminal --window-with-profile=Zork --hide-menubar --geometry=80x35 --command=/home/jamesl/zork/zork

Double-clicking on the calling script opens a terminal window, with a few cosmetic customizations (like using the "gnome-home" icon, to represent the "big white house with a boarded front door", and a color scheme that suggests an amber-screen terminal), then launches the game: Welcome to Dungeon. This version created 11-FEB-87.
You are in an open field west of a big white house with a boarded
front door.
There is a small mailbox here.
>
Now why can't there be a tutorial for something like that? Why can't they put an example of something like that in the "Dummies" book?

hbquikcomjamesl
03-22-2005, 07:09 AM
Oh, yes, and I almost forgot: it was while I was going through the PREFERENCES dialog to make invisible files visible that I found a setting to always "Execute files when they are clicked" to avoid the dialog when clicking on scripts.

Bill Catherall
03-22-2005, 08:52 AM
Now why can't there be a tutorial for something like that? Why can't they put an example of something like that in the "Dummies" book?
Because there are so many permutations and uses of scripts there is no possible way to come up with examples and tutorials for everything or anything you'll ever come across. So they opt to just give a basic understanding of what a script is and hope the users are smart enough to figure out the rest on their own.

With Linux you really have to be willing to just roll up your sleeves and get dirty and even make a few mistakes to learn how to use the real power under the hood. But the beauty is it can also be really easy to use for the other 98% of the usual computer tasks (given the right distribution).

I recently picked up a book called How Linux Works (by Brian Ward) that is pretty good. It doesn't give tutorials for anyone one Linux distribution, but covers the basic underlying structure common to them all and how to use it.

Opus1guy
03-22-2005, 10:44 AM
This thread is scary.

:)


advertisement
advertisement