delphi programming forums mysql charset mget recursive synonimos
free ventrilo servers hosting cs javascript delay python find in list
Back Forum New
abstract:

I am using unix, how can  I run that programe from the command line?
Thanks


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

TOP

Well, first you'll want to make sure that you have execute permissions for the file. ls -l the file.
Code:
  1. $ ls -l index.php
  2. -rw-r--r--  1 iota users 1302 Jun  9 23:28 test.php
Copy Code
From the above we can see that it is not executable for the owner,  so we'll chmod it.
Code:
  1. $ chmod u+x test.php
  2. -rwxr--r--  1 iota users 1302 Jun  9 23:28 test.php
Copy Code
Once that's done you can execute it by typing
Code:
  1. $ . test.php
  2. Hello, world!
Copy Code
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:
  1. $ php test.php
  2. Hello, world!
Copy Code
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:
  1. $ export PATH=$PATH:.
  2. $ test.php
  3. Hello, world!
Copy Code

TOP

thanks a lot for your help



I am using unix, how can  I run that programe from the command line?
Thanks

TOP

Back Forum