LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 09-15-2004, 10:50 AM   #1
kaon
Member
 
Registered: Dec 2003
Location: Hong Kong SAR
Distribution: Slackware 9.1, 10.x, slackware-current
Posts: 186

Rep: Reputation: 30
command execute without ./


Hi all,

I recently found that:

tsun@sKex:~/vnc-4.0-x86_linux$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/usr/lib/java/bin:/usr/lib/java/jre/bin:.

Commands in the self directory can be run without ./!
Just found a little dot in the last.

How can I just remove that . from $PATH.

Thanks.

Last edited by kaon; 09-15-2004 at 10:52 AM.
 
Old 09-15-2004, 11:37 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
Try look in your ~/.bashrc or ~/.bash_profile if there are not instructions lines which set your PATH with this dot..

Or you can add 2 lines in bottom of ~/.bashrc like this :

PATH=$(echo $PATH | perl -e 's/:?\.:?/:/')
export PATH
 
Old 09-15-2004, 12:11 PM   #3
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 51
Edit: Ignore this post, I didn't see the latest dot

kaon, do you mean commands that are in those directories? If so, that's the desired effect of the PATH variable.
 
Old 09-15-2004, 12:26 PM   #4
kodon
Member
 
Registered: Jul 2004
Location: [jax][fl][usa]
Distribution: Slackware64-current
Posts: 796

Rep: Reputation: 31
on my box the directive to add ./ for non-root users
is the last section of /etc/profile
 
Old 09-15-2004, 01:13 PM   #5
kaon
Member
 
Registered: Dec 2003
Location: Hong Kong SAR
Distribution: Slackware 9.1, 10.x, slackware-current
Posts: 186

Original Poster
Rep: Reputation: 30
Yeah, I just found that too!

Do not know why such bad setting appears in slackware.
 
Old 09-15-2004, 01:15 PM   #6
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
You right kodon, I didn't noticed that because of some PATH tweakings in my ~/.bashrc

What a strange feature, I certainly don't want that
 
Old 09-15-2004, 01:31 PM   #7
kaon
Member
 
Registered: Dec 2003
Location: Hong Kong SAR
Distribution: Slackware 9.1, 10.x, slackware-current
Posts: 186

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by Cedrik

Or you can add 2 lines in bottom of ~/.bashrc like this :

PATH=$(echo $PATH | perl -e 's/:?\.:?/:/')
export PATH
I found that this would yield a null string for $PATH.
P.S. I do not know perl at all
 
Old 09-15-2004, 03:44 PM   #8
kodon
Member
 
Registered: Jul 2004
Location: [jax][fl][usa]
Distribution: Slackware64-current
Posts: 796

Rep: Reputation: 31
just wondering why it's such a bad idea for non-roots to have ./ in path?
i kinda understand why you might not want root to have it...i think
 
Old 09-15-2004, 04:42 PM   #9
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
just wondering why it's such a bad idea for non-roots to have ./ in path?
For my part, simply because I am used to use ./ to execute scripts in current directory, say it is for a personal habit

I found that this would yield a null string for $PATH.
P.S. I do not know perl at all


My bad, I forget the -p switch
Code:
PATH=$(echo $PATH | perl -pe 's/:?\.:?/:/')
export PATH
 
Old 09-15-2004, 04:53 PM   #10
kodon
Member
 
Registered: Jul 2004
Location: [jax][fl][usa]
Distribution: Slackware64-current
Posts: 796

Rep: Reputation: 31
i don't understand

i thought with ./ in path
you would be able to do
both [script] and ./[script]
 
Old 09-15-2004, 05:03 PM   #11
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
Ok, I have a home directory with a 'bin' subdirectory which is in my PATH and if I consider a custom script stable, I put it here. So I used to do a difference between 'temp' scripts like, experiencing script, configure script from programs packages etc...
I simply used to ./ all scripts that are not in my PATH and I don't want to be able to execute them directly by their name.
 
Old 09-15-2004, 06:14 PM   #12
kodon
Member
 
Registered: Jul 2004
Location: [jax][fl][usa]
Distribution: Slackware64-current
Posts: 796

Rep: Reputation: 31
ok
think i get it now

you should not run unstable(possibly malicious)
scripts from a directory in $PATH, because they
would have access to $SELF...

thanks, i had wondered about that with PHP also

off to change that /etc/profile
 
  


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
execute system command from c alaios Programming 2 07-19-2005 08:45 AM
execute system command in c alaios Programming 3 07-13-2005 06:26 AM
remote command execute telnet with 1 command MPowers Linux - Networking 2 06-30-2005 07:31 AM
execute command from c code alaios Programming 3 06-06-2005 06:26 AM
Execute Command lawrencegoodman Linux - Newbie 2 10-23-2003 09:36 AM


All times are GMT -5. The time now is 01:05 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration