LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 12-18-2015, 10:33 AM   #1
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 761

Rep: Reputation: Disabled
Executing commands in local directory without directory path


I am a little confused. Why must I include the directory path when executing bacwi?

Code:
pi@raspberrypi ~/bacnet-stack-0-8-0/bin $ pwd
/home/pi/bacnet-stack-0-8-0/bin
pi@raspberrypi ~/bacnet-stack-0-8-0/bin $ ls -l bacwi
-rwxr-xr-x 1 pi pi 106865 Dec 12 16:05 bacwi
pi@raspberrypi ~/bacnet-stack-0-8-0/bin $ bacwi -1
-bash: bacwi: command not found
pi@raspberrypi ~/bacnet-stack-0-8-0/bin $ ./bacwi -1
Received I-Am Request from 1234, MAC = 192.168.1.201.186.192
Received I-Am Request from 1234, MAC = 192.168.1.201.186.192
;Device   MAC (hex)            SNET  SADR (hex)           APDU
;-------- -------------------- ----- -------------------- ----
  1234    C0:A8:01:C9:BA:C0    0     00                   1476
;
; Total Devices: 1
pi@raspberrypi ~/bacnet-stack-0-8-0/bin $
 
Old 12-18-2015, 10:42 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
What is the output of this command?
Code:
echo $PATH
On my system my home directory is not included in the PATH variable.
jdk

Last edited by jdkaye; 12-18-2015 at 10:43 AM.
 
1 members found this post helpful.
Old 12-18-2015, 10:42 AM   #3
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,703

Rep: Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678
The current working directory is not normally part of the search path for comands, try
Code:
echo $PATH
To see what directorys get searched, if you want to run a command in the current directory without changing the PATH variable use "./" which is a releative path to the current directory so use
Code:
./bacwi
 
1 members found this post helpful.
Old 12-18-2015, 10:45 AM   #4
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
@Keith Hedger
Great minds think alike.
jdk
 
Old 12-18-2015, 10:47 AM   #5
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,703

Rep: Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678
Quote:
Originally Posted by jdkaye View Post
@Keith Hedger
Great minds think alike.
jdk
Aint it spooky when that happens.
 
Old 12-18-2015, 10:51 AM   #6
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 761

Original Poster
Rep: Reputation: Disabled
Code:
pi@raspberrypi ~/bacnet-stack-0-8-0/bin $ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
pi@raspberrypi ~/bacnet-stack-0-8-0/bin $
Thanks. I incorrectly thought that the current directory was always part of the search path for commands.
 
Old 12-18-2015, 10:53 AM   #7
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,703

Rep: Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678
Don't forget to mark the thread SOLVED
 
Old 12-18-2015, 10:58 AM   #8
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
Glad to have been of service. As a service to others please mark this thread as [SOLVED]. You can use the Thread Tools menu located above your first post in this thread (see the attachment).
jdk
Attached Thumbnails
Click image for larger version

Name:	lq_threadtools.png
Views:	6
Size:	26.8 KB
ID:	20325  
 
Old 12-18-2015, 11:00 AM   #9
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
Great minds still think alike. What did you have for breakfast?
jdk
 
Old 12-18-2015, 11:04 AM   #10
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,703

Rep: Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678
Quote:
Originally Posted by jdkaye View Post
Great minds still think alike. What did you have for breakfast?
jdk
Don't eat breakfast it's for wimps!
 
Old 12-19-2015, 07:21 AM   #11
normanlinux
Member
 
Registered: Apr 2013
Location: S.E. England
Distribution: Arch
Posts: 161

Rep: Reputation: Disabled
No current directory in $PATH

There is a very good reason why there is no current directory (.) in your $PATH

It is a potential security risk - although it would, of course, be comforting for people coming from windows to see that they could f**k up their system in a way that they were used to.

Back in the eighties it was common (normal?) to prepend $PATH with current directory. However this creates a security hole in that an executable file, in your home directory, with the same name as a system program could do all manner of nasty things. So we moved to putting the current directory at the end of the $PATH.

Then it was realised that there could still be problems, so for the past 20 - 25 years the advice has always been not to include current (or home) directory in $PATH - but to use ./ to reinforce that you consciously wish to use a local file.

Nothing wrong with having a bin directory within your home directory - in fact it's a good idea - but put it at the end of your $PATH
 
  


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
eval $PATH produces a path list followed by No such file or directory warning Alpha90 Linux - Newbie 10 11-04-2012 10:16 AM
on make -j 2.. executing default commands.prints..leaving directory Error 2 manoj7410 Linux - Distributions 5 06-15-2012 11:08 PM
How to Copy files from local directory to a particular directory using alias dynamics Linux - Newbie 7 09-11-2009 04:19 PM
How to rsynce the actual directory path instead of just the directory at the end of Niceman2005 Linux - General 5 04-08-2005 07:58 PM
Executing commands without using the full path.. LinuxBAH *BSD 2 12-02-2003 07:16 PM

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

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