[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Darn dot slash ./

Posted on 2006-05-24
8
Medium Priority
?
331 Views
Last Modified: 2008-03-03
Why can I run an app in a shell by typing ./appname but not form the directory above it called apps by calling /apps/appname or ./apps/appname or /apps/.appname

Whats going on?
0
Comment
Question by:cglenn3932
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 25

Accepted Solution

by:
Cyclops3590 earned 1500 total points
ID: 16757008
because you have to reference the actual file.  Here's how linux app calling works
if the app is in a directory that is part of your PATH env var then you can just type
appname
at the command line and it'll work, however if the app isn't in one of those the directories then you have to either reference the relative path name of the app or the absolute path name
for example, you want to run /root/apps/appname
you are in /home/user
you can run appname by typing
/root/apps/appname
or
../../root/apps/appname
if you are in /root/apps you can type
./appname
or
/root/apps/appname
if you are in /root/apps/someotherdir
then you can type
/root/apps/appname
or
../appname

the .. means go one directory back and the single . means reference the current directory
so
./
means the current directory
../
means one directory back and
/
means the absolute root parent directory

understand?
0
 

Author Comment

by:cglenn3932
ID: 16757091
OK, so how do I add things to my path?
0
 
LVL 25

Expert Comment

by:Cyclops3590
ID: 16757149
I use bash as my shell and that path is stored in the
/home/<username>/.bash_profile
file.  also at the command line you can do
PATH=$PATH:<path to be added>

mind you the path should always be absolute to avoid any weird reactions and you should NEVER add "." the single dot to your path var.  This means look at your current directory.  this is a potential security risk because if you get hacked, then someone could put a bin file on your box and just wait until you run that file and then get you then.

basically, just be real careful what you put in your path
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 14

Expert Comment

by:ppfoong
ID: 16757174

Hmm... you should be able to, unless there is permission problem.


What do you see when you "ls -l | grep apps" and "ls -l apps"? Run this command when you are one level above appname.

If you can see "x" is granted for the user/group who execute the command, then we need to check further. Else, use chmod to grant the "x" permission as appropriate.


0
 

Author Comment

by:cglenn3932
ID: 16757277
So, I am running this from a php script.  So, if I type what you suggest at the bash, it's permanent then?
0
 
LVL 14

Expert Comment

by:ppfoong
ID: 16757299

If you run from php script, give the full absolute path, eg "/path/to/apps/appname", because "./" to the php script might be somewhere else.

0
 
LVL 25

Expert Comment

by:Cyclops3590
ID: 16759792
yes definitely the absolute path. Trust me, if you use relative paths in a php script it can get very messy very fast and hard to trouble shoot what is happening.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 16763818
>  So, I am running this from a php script.  So, if I type what you suggest at the bash, it's permanent then?
no it's not permanent, and your shell has nothing to do with your php script, usually
Use full path in php as already suggested.
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month20 days, 2 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question