LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 09: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 09:52 AM.
 
Old 09-15-2004, 10:37 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
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, 11:11 AM   #3
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
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, 11:26 AM   #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, 12: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, 12:15 PM   #6
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
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, 12: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, 02: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, 03:42 PM   #9
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
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, 03: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, 04:03 PM   #11
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
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, 05: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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:30 PM.

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
Open Source Consulting | Domain Registration