Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 21st June 2007, 21:46
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,044
Thanks: 269
Thanked 154 Times in 133 Posts
Default How to pass a posted variable from Bash to PHP?

Anyone here who might know how I can pass a posted variable from Bash to a PHP script?

When I run in Bash
Code:
php logit.php
all is working fine, but when I try to add a variable like
Code:
php logit.php?takethis=123123
I get an error from Bash saying that the file can not be found!

Calling
Code:
php logit.php?takethis=123123
from the website does work fine.

The problem with Bash is the ?takethis=123123 part!

Can the call with the ?takethis=123123 to the PHP page been done an other way in Bash?
__________________
Never execute code written on a Friday or a Monday.

Last edited by edge; 21st June 2007 at 21:48.
Reply With Quote
Sponsored Links
  #2  
Old 21st June 2007, 23:12
aqua aqua is offline
Member
 
Join Date: Mar 2006
Posts: 60
Thanks: 4
Thanked 3 Times in 3 Posts
Default

i don't use php but you can try:

Quote:
php '?takethis=123123'
Reply With Quote
  #3  
Old 22nd June 2007, 15:06
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,751 Times in 2,581 Posts
Default

Maybe you can add this function:

Code:
function getInput() {
  $fr = fopen("php://stdin", "r");
  while (!feof ($fr)) {
    $input .= fgets($fr);
  }
  fclose($fr);
  return $input;
}

$takethis = getInput();
to your PHP script and then do something like this:

Code:
echo 123123 | php logit.php
Of course, you should check the $takethis variable before you continue (to avoid that someone tries to pass harmful code to your script).
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
The Following User Says Thank You to falko For This Useful Post:
edge (25th April 2011)
  #4  
Old 25th April 2011, 22:27
pakogah pakogah is offline
Member
 
Join Date: Feb 2008
Posts: 56
Thanks: 13
Thanked 2 Times in 2 Posts
 
Default

thank you very much Falko

you save my day (or night)
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Freebsd 6.1 support misterm Installation/Configuration 10 9th April 2009 10:29
php eating cpu shajazzi Server Operation 15 15th August 2007 02:19
Slightly Confused (DNS & Server Help) JohnnyBGoode Installation/Configuration 26 14th August 2007 10:54
Apache2 Freezes celtic Server Operation 31 28th May 2007 18:18


All times are GMT +2. The time now is 07:46.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.