LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 04-26-2005, 08:04 PM   #1
Alexander.s
Member
 
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
Boby
Member
 
Registered: Feb 2004
Posts: 781

Rep: Reputation: Disabled
Hello!

Do you mean you wanna run a php script from the command line?
http://www.php.net/manual/en/features.commandline.php

PHP Code:
#!/usr/bin/php
<?php

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

This is a command line PHP script with one option.

  Usage:
  <?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.

<?php
} else {
   echo 
$argv[1];
}
?>
Sorry if I didn't understood the right question.
Boby
 
Old 04-27-2005, 01:52 PM   #3
Orkie
Member
 
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
Alexander.s
Member
 
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 action=bashscript.sh 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
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

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


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:03 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration