How to create command to start a program without going to that folder?
I know this should be a simple thing to do, but I've searched around, and haven't found the way to do it- partially because I'm not sure what to call it.
I want to create a command that will start a program. I want to be able to open the program with this command regardless of whether I am working in the directory where the program is located or not. Also, is there a name for doing this? I've adjusted my .bash_profile file to include in my $PATH the directory where the program is located, but it still is not working, and I'm not sure what else to try. :Pengy: Thanks for your help!!! janestclaire |
Try something like this:
/bin/sh -c "/usr/bin/gimp-2.2" or -e sh -c \"/usr/bin/elinks\" I use IceWM and looking at all of the programs in the menu those are the 2 commands that are set to launch various programs. For apps that aren't on the menu I use Grun, it is an app launcher, I just browse to where the app is or type in the name. |
I think I know what you mean. I don't know a specific name for it. For my example I'll use doom legacy, because that has a similar issue. If I type from my home directory:
/mnt/Programs/doom/lsdldoom -iwad doom.wad It won't work because I have to be in the /mnt/Programs/doom directory for lsdldoom to find the iwad. I could also provide the path to the iwad in the same command but that can become a long command to type and that's more possibility to make typos. I would create a script like this: #!/bin/bash cd /mnt/Programs/doom lsdldoom -iwad doom.wad cd ~ and save it in my ~ directory. Don't forget to make it executable. |
Thanks Dracolich- that worked! (at least it seems to be working)
Is this a "shell script"? Also, you said to make sure it is executable. I'm not sure how, but I took the example you gave, modified it for my program, and made the file using vi editor. Then I just saved it into my home directory. When I typed the name of the vi file into the command line it opened my program. But, I didn't do anything special to make it executable-- can you explain this a little more? Thanks again!! janestclaire |
Use ; for multiple commands, i.e.,
cd /mnt/Programs/doom ; lsdldoom -iwad doom.wad ; cd ~ does multiple commands. [And use ; as often as you want.] Sheng-Chieh |
Yeah, I know about the semicolons. That just makes the script two lines instead of four.
This qualifies as a shell script - a script file that executes a series of shell commands. Maybe RH does some things automagically that Slackware doesn't. If you type ls -l <filename> for your script file what permissions do you see? (e.g. -rwxrwxr--) X's indicate execute permission. When I make a script I have to use 'chmod +x filename' to add the execute permission before it'll run. |
I'm not sure why it worked before, because after ls -l, the permissions were -rw-r-----. However, I made it an executable just in case.
Sorry- I didn't think about looking at the ls -l to figure out that it was an executable. I'm still pretty new to this stuff. Thanks again! janestclaire |
All times are GMT -5. The time now is 02:41 AM. |