|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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! |
|
#3
|
|||
|
|||
|
thanks a lot for your help
|
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Running from command line? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|