LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 05-24-2008, 03:39 PM   #1
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,003

Rep: Reputation: 67
Invoking a PHP script - sometimes the full path is required


I have noticed that sometimes I can invoke a php script like this:
Code:
linux_prompt# php -q my_script.php
but other times I must type in the full path to the php executable like this:
Code:
linux_prompt# /usr/bin/php5 my_script.php
Why is that? I'm guessing there's an alias somewhere. Is it in my bash profile? Is it possible to create one alias that applies to *all* users of a linux box? Also, is it safe to use the path /usr/bin/php every time or will that path vary by linux distribution or php install?

Any help would be very much appreciated.
 
Old 05-25-2008, 02:13 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Are you seeing that different behaviour as the same user,
or are you su'ed to someone else?


Cheers,
Tink
 
Old 05-25-2008, 03:13 PM   #3
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,003

Original Poster
Rep: Reputation: 67
I'm not talking about different behavior on a single machine. I'm talking about different behavior from server to server.
 
Old 05-25-2008, 07:12 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
For server to server differences, it means its not always being set in the PATH var.
Fundamentally, you've got
/etc/profile
which is applied to all user logins, and
.bash_profile
which is a hidden file in the home dir of each user and can contain different info eg PATH definitions, for each user.
HTH
 
Old 05-26-2008, 06:38 PM   #5
seraphim172
Member
 
Registered: May 2008
Posts: 101

Rep: Reputation: 15
PATH issue

If the location of an application is not in your PATH, then you will have to type the full path name - this is true for every application, not only for PHP.

To run PHP from the command-line it has to have been built with the CLI option. This can be different among different servers.

Linux Archive

Last edited by seraphim172; 06-25-2008 at 05:30 AM.
 
  


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
how to use script sed with full path azeus Programming 8 03-14-2008 06:23 AM
Run any Script without metioning the full path shipon_97 Linux - Newbie 2 08-08-2006 11:49 PM
get full path of uploaded file in php spoody_goon Programming 2 05-10-2005 08:32 PM
How to start a Tcl/Tk script by simply invoking the script file itself ? cyu021 Programming 2 10-10-2004 12:00 PM
php mail script return path richard22 Linux - Software 1 08-22-2003 05:10 AM


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