Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 04-26-2005, 08:04 PM   #1
Registered: Sep 2004
Location: Sweden
Distribution: Slackware, Gentoo!
Posts: 115

Rep: Reputation: 15
Does PHP make good friends with bash?

What i mean is, i know how to write a cgi script in bash that will insert data into my database. But my search script is in PHP.

Could i just write my cgi script and link it to the index.php file.
Like i do with the index.html file?

Am i making any sense here?

thanks / Alexander
Old 04-27-2005, 01:40 PM   #2
Registered: Feb 2004
Posts: 781

Rep: Reputation: Disabled

Do you mean you wanna run a php script from the command line?

PHP Code:

if ($argc != || in_array($argv[1], array('--help''-help''-h''-?'))) {

This is a command line PHP script with one option.

  <?php echo $argv[0]; ?> <option>

  <option> can be some word you would like
  to print out. With the --help, -help, -h,
  or -? options, you can get this help.

} else {
Sorry if I didn't understood the right question.
Old 04-27-2005, 01:52 PM   #3
Registered: Mar 2005
Distribution: Breezy Badger
Posts: 248

Rep: Reputation: 30
I think Alexander.s meant can you have the page in index.cgi but the search in index.php and link them together. You can do by setting up the PHP script so that it can run from the command line as Boby has described (by adding the #!/blah line at the top) and then executing it from the bash script as you would for any other system command. The bash script will then be able to read any output from the PHP script as normal on the command line.
Old 04-27-2005, 04:25 PM   #4
Registered: Sep 2004
Location: Sweden
Distribution: Slackware, Gentoo!
Posts: 115

Original Poster
Rep: Reputation: 15
i meant bash as the script language bash i wrote a backend script in bash and im wondering if it will work to do an in the index.php file
like i do in the index.html file

Thanks for the help!
Old 04-27-2005, 04:40 PM   #5
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
Just create a php script that parse the form variables, then run the
bash script with the variables as arguments


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
BASH problems: "configure, make, make install" commands don't work ditch* Linux - General 3 07-19-2005 04:37 PM
Good book to learn bash? J_K9 Linux - Newbie 14 11-26-2004 01:38 AM
good use of php sessions acid_kewpie Programming 2 07-23-2003 02:21 AM
good PHP book aeshley Programming 5 01-23-2002 04:24 PM
good PHP book aeshley Linux - Newbie 1 01-11-2002 12:23 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:27 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration