UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 24th, 2006, 11:44 AM
isheikh isheikh is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Posts: 544 isheikh New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 2 Days 7 h 39 m 29 sec
Reputation Power: 0
Running from command line?

Hi, suppose I have a program test.php. I am using unix, how can I run that programe from the command line?

Thanks
__________________
web developer

Reply With Quote
  #2  
Old August 25th, 2006, 07:54 PM
mu's Avatar
mu mu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Location: Dublin, Ireland
Posts: 174 mu User rank is Sergeant Major (2000 - 5000 Reputation Level)mu User rank is Sergeant Major (2000 - 5000 Reputation Level)mu User rank is Sergeant Major (2000 - 5000 Reputation Level)mu User rank is Sergeant Major (2000 - 5000 Reputation Level)mu User rank is Sergeant Major (2000 - 5000 Reputation Level)mu User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 23 h 39 m 56 sec
Reputation Power: 39
Well, first you'll want to make sure that you have execute permissions for the file. ls -l the file.

Code:
$ ls -l index.php
-rw-r--r--  1 iota users 1302 Jun  9 23:28 test.php


From the above we can see that it is not executable for the owner, so we'll chmod it.

Code:
$ chmod u+x test.php
-rwxr--r--  1 iota users 1302 Jun  9 23:28 test.php


Once that's done you can execute it by typing
Code:
$ . test.php
Hello, world!


provided that you've included the appropriate shebang as the first line, i.e. #!/usr/bin/php or something to that effect. Alternatively you could just do

Code:
$ php test.php
Hello, world!


Executing it like that would eliminate the need to make the file executable.

Here's a useful tip, if you add a . (current directory) to your PATH variable) you can execute scripts/programs etc. in the current directory without having to type the . in front of the script name. (Add it to your rc file to make it permanent)

Code:
$ export PATH=$PATH:.
$ test.php
Hello, world!

Reply With Quote
  #3  
Old August 28th, 2006, 07:41 AM
isheikh isheikh is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Posts: 544 isheikh New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 2 Days 7 h 39 m 29 sec
Reputation Power: 0
thanks a lot for your help

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Running from command line?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway