FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Converting Perl to PHP, testing CLI with $_POST (newbie)
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Converting Perl to PHP, testing CLI with $_POST (newbie) [message #172075] Sun, 30 January 2011 03:09 Go to previous message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma:
Member
I have made much progress converting my working Perl script to the
equivalent in PHP. Mostly I used the -l lint switch from the command line
interface on my localhost Apache server, and I was able to pass the syntax
check. Then I ran the script using a batch file with command line arguments
as CGI variables, but they do not seem to be read into the $_POST array. My
batch file is as follows:

C:\xampp\php\php-cgi eventprocessor.php --
Full_Name="MyName";Email="MyEmail"; ...

I am attempting to read the variables as

$in = $_POST ; // Get the CGI input variables
echo("Name: " . $_POST["Full_Name"] . "\n");
echo("Name: " . $in[Full_Name] . "\n");
echo("Name: " . $argv[2] . "\n");

This is essentially what I used for the Perl script and it works fine. The
last line above echoes the entire set of CGI variables (since there are no
spaces), and #argv[1] is just "--". I also used the command line
eventprocessor.php < CGIVARS.txt, but that did not work.

This did not seem to help:
http://php.net/manual/en/features.commandline.options.php

I should be able to use an HTML form and use POST to run the script, but
there should be a way directly from the CLI as there was for Perl.

So far I have found PHP much easier to use than Perl, so if I can get past
this hurdle I will be well on my way to make a determination as to what
language I will use for scripting.

Thanks,

Paul
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: passing variable to a nested array
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 14:37:36 GMT 2024

Total time taken to generate the page: 0.05365 seconds