LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-31-2005, 12:12 PM   #1
janestclaire
LQ Newbie
 
Registered: Sep 2004
Location: Indiana
Distribution: RedHat 9
Posts: 4

Rep: Reputation: 0
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.

Thanks for your help!!!

janestclaire

Last edited by janestclaire; 08-31-2005 at 12:14 PM.
 
Old 08-31-2005, 12:22 PM   #2
craigevil
Senior Member
 
Registered: Apr 2005
Location: OZ
Distribution: Debian Sid
Posts: 4,734
Blog Entries: 12

Rep: Reputation: 462Reputation: 462Reputation: 462Reputation: 462Reputation: 462
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.
 
Old 08-31-2005, 02:52 PM   #3
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,178

Rep: Reputation: 47
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.
 
Old 08-31-2005, 03:48 PM   #4
janestclaire
LQ Newbie
 
Registered: Sep 2004
Location: Indiana
Distribution: RedHat 9
Posts: 4

Original Poster
Rep: Reputation: 0
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
 
Old 08-31-2005, 03:49 PM   #5
shengchieh
Member
 
Registered: Jul 2004
Location: Palo Alto, CA
Distribution: #! Korora
Posts: 472

Rep: Reputation: 30
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
 
Old 08-31-2005, 04:31 PM   #6
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,178

Rep: Reputation: 47
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.
 
Old 08-31-2005, 07:42 PM   #7
janestclaire
LQ Newbie
 
Registered: Sep 2004
Location: Indiana
Distribution: RedHat 9
Posts: 4

Original Poster
Rep: Reputation: 0
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
command to create shortcut for an application in the start menu for linux neerajchaudhari Linux - Software 1 08-29-2005 03:11 AM
how create a folder/permission rusmi Linux - Newbie 7 02-11-2005 10:04 AM
how can i default the max folder file size when it create inside a folder antony_csf Linux - Software 1 06-17-2004 02:26 AM
how to i create a folder under root? santasballz Linux - Newbie 3 02-27-2004 06:25 PM
Create new folder error! Rex_chaos General 3 10-05-2001 02:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration