LinuxQuestions.org
Register a domain and help support LQ
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 02-19-2005, 01:34 AM   #1
Umanga
Member
 
Registered: Aug 2004
Location: Sri Lanka
Distribution: Debian Etch
Posts: 36

Rep: Reputation: 15
running programs in console?


Hy guys!
I've got a silly question,

Some programs(normally which I created using g++) must run as
'./myprogram'

but other programs like java run by just typing
'java'

can I make 'myprogram' also runnable without that ugly dot and slash??


Thanks
 
Old 02-19-2005, 01:42 AM   #2
SirSlappy
Member
 
Registered: Jun 2003
Location: Glendale AZ
Distribution: Slackware 10
Posts: 153

Rep: Reputation: 30
well

Well, the issue here is "/usr/local/bin" and "/usr/sbin"

These directories hold binary programs such as "ls" or the forementioned "java" and since they are in this directory they are accessible by simply typing them without that nasty "./"

"./" simply means ... run from this directory. i.e. ./randomprogram = please run the binary file randomprogram from this directory.

So, if you want to NOT have to type "./program" you will have to copy the binary file into the /usr/local/bin/ directory.

Have fun.
 
Old 02-19-2005, 08:10 AM   #3
JoannesX
Member
 
Registered: Dec 2004
Location: Brazil
Distribution: Slackware
Posts: 99

Rep: Reputation: 15
ok, take a look at a variable that is set automatically for linux:
PATH

to show its content, type "echo $PATH"..

you'll see a list of directories separated by a ":"
every executable that is in one of those directories will be executed if you just type their names..

for example /sbin/lilo is an executable, and /sbin is in the PATH..
you just have to type lilo and it's executed


If you want to add your own directory to the PATH, do this:
PATH="$PATH:/mydirectory/"

but that applies only for your current session, if you want it to apply for all the others,
you have to edit the file /etc/profile..
search for the lines containing the PATH content and add your dir to this group of dirs..
DON'T forget that the directories must be separated by ":"

Last edited by JoannesX; 02-19-2005 at 08:12 AM.
 
Old 02-19-2005, 08:18 AM   #4
__J
Senior Member
 
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
uhhhh, no. I'm gonna warn you though this could be considered a security risk by some. Anyway, what you want to do is add the current directory in your PATH ( but it will always be the current directory, not a static directory like "/home/programs/bin" or something like that). Some distro's do this and some do not. here is what you need to add to /etc/profile:

# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
PATH="$PATH:."
fi



I would copy it verbatim for security reasons.
 
Old 02-22-2005, 05:41 PM   #5
JoannesX
Member
 
Registered: Dec 2004
Location: Brazil
Distribution: Slackware
Posts: 99

Rep: Reputation: 15
What do you really mean with "not a static directory"?

'cause I have added /ext3/scripts/shell to my PATH just to have a separated dir for my scripts..
and it's totally static so far..

I just had to create a .bash_profile for each user and add this to the PATH there, in order to let them run my scripts too...

Sorry if I misunderstood..
 
Old 02-22-2005, 08:34 PM   #6
shengchieh
Member
 
Registered: Jul 2004
Location: Palo Alto, CA
Distribution: #! Korora
Posts: 472

Rep: Reputation: 30
Suggestion:

If you use these programs often, you can add it into the
menu or create a desktop icon.

Menu:
-> K (window equivalent of start)
-> Appl...
-> System
-> Menu Editor
[could be be diffenrence based on distribution)
Icon:
wiggle to executable on a file manager
Left-click and hold and drag to desktop.
choose to link.

Sheng-Chieh
 
Old 02-22-2005, 10:30 PM   #7
JoannesX
Member
 
Registered: Dec 2004
Location: Brazil
Distribution: Slackware
Posts: 99

Rep: Reputation: 15
yes that works if you're running X..
But the questions here is how to run programs in console...
 
  


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
pinkish rectangles on console programs dosnlinux Linux - Newbie 2 05-30-2005 08:26 AM
Linux Console Programs tekhead2 Linux - Newbie 2 08-01-2004 12:50 AM
how to start console-programs out of fluxbox menu? Vincent Linux - Newbie 2 02-24-2004 06:10 AM
running a console app cratos Programming 8 11-06-2003 10:58 AM
running programs independant to the virtual console Cubix Linux - Newbie 4 07-16-2003 03:48 PM


All times are GMT -5. The time now is 10: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