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.
Thread Tools Display Modes
Old 21st June 2007, 21:46
edge edge is offline
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
php logit.php
all is working fine, but when I try to add a variable like
php logit.php?takethis=123123
I get an error from Bash saying that the file can not be found!

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
Old 21st June 2007, 23:12
aqua aqua is offline
Join Date: Mar 2006
Posts: 60
Thanks: 4
Thanked 3 Times in 3 Posts

i don't use php but you can try:

php '?takethis=123123'
Reply With Quote
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

Maybe you can add this function:

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

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

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).
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)
Old 25th April 2011, 22:27
pakogah pakogah is offline
Join Date: Feb 2008
Posts: 56
Thanks: 13
Thanked 2 Times in 2 Posts

thank you very much Falko

you save my day (or night)
Reply With Quote


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.