LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-31-2008, 06:22 PM   #1
Dafydd
Member
 
Registered: Oct 2008
Posts: 311

Rep: Reputation: 23
Calling PHP5 from a shell script


I have upgraded to ubuntu 8.04 with all the updates offered.

On a previous unnamed Linux system I had some bash script files that ran on PHP-4.

On my new installation, when I run the following code:
Code:
#!/bin/bash

main()
{
cat pdlist12 | ( \
     while read admin; \
     do check_link $admin; done \
     )

}

PHP_EXEC='php -r'

check_link()
{
    member_email=$1

##line 19    
    php -f mailsender.php "$member_email" "two"  
}
I use to get this error:
Quote:
./send.sh: line 19: php: command not found
Investigation found I did not have any 'php' installed so I installed Apache2 as that was the only comments I could find in the 'ubuntu' forums concerning 'php'.

Now I get this error:

Quote:
./send.sh: line 19: php: command not found
dave@gadabout:~/tffrobot$ ICE default IO error handler doing an exit(), pid = 8586, errno = 11
So I tried this;
Quote:
dave@gadabout:~/tffrobot$ sudo apt-get install php
[sudo] password for dave:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package php is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package php has no installation candidate

dave@gadabout:~/tffrobot$ sudo apt-get install php5
Reading package lists... Done
Building dependency tree
Reading state information... Done
php5 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
dave@gadabout:~/tffrobot$
If I change the 'php' in both instances to 'php5' I still get the command not found error.

Is there a HOWTO for me to read? Do I need to rewrite my code?
Can anyone help?

TIA
Dave
 
Old 10-31-2008, 06:39 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
You're definitely on the right track:

1. You really want PHP5 (not PHP4, if you can avoid it)

2. You *should* be able to call PHP5 from a command line or script... only now it will now be called "php5" (instead of the old name, "php").

Verify that PHP5 is installed and available from a terminal window:
Quote:
php5 --version
3. Now you've got a choice:
a) change your script (to use "php5" instead of "php")
b) create a symbolic link to alias php5 to "php"

I vote for "a)". The syntax for a symbolic link would be:
EXAMPLE: ln -s /usr/bin/php5 /usr/bin/php

4. Perhaps maybe when you edited your script, you found some (but not all) instances of "php", and you simply need to find and change the rest?

'Hope that helps .. pSM
 
Old 10-31-2008, 07:31 PM   #3
Dafydd
Member
 
Registered: Oct 2008
Posts: 311

Original Poster
Rep: Reputation: 23
PaulSM4............
I am always amazed how a simple comment will trigger something.

Your comment 'try php5 --version'. I don't why but I had not tried that.

It returned:
Code:
dave@gadabout:~$ php5 --version
The program 'php5' is currently not installed.  You can install it by typing:
sudo apt-get install php5-cli
bash: php5: command not found
dave@gadabout:~$
So I did and can now get this:
Quote:
dave@gadabout:~$ php5 --version
PHP 5.2.4-2ubuntu5.3 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 23 2008 06:44:49)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies


dave@gadabout:~$ php --version
PHP 5.2.4-2ubuntu5.3 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 23 2008 06:44:49)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
dave@gadabout:~$
Thank you very much for your help. The 300 newsletters have been sent.

Dafy
 
  


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
Calling perl script and passing variable from php script hosea Programming 5 10-21-2008 08:01 AM
calling function shell script very simple ones knockout_artist Linux - Newbie 2 05-15-2008 12:01 PM
how to pass a variable from a called script back to the calling script steven.c.banks Linux - General 2 05-05-2008 02:00 PM
Executing shell script with shell_exec from PHP5 on Apache2 gives timeout raven Programming 1 02-06-2008 02:04 AM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM


All times are GMT -5. The time now is 06:13 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration