Link to home
Start Free TrialLog in
Avatar of Starquest321
Starquest321

asked on

PHP forward to pipe

Hi

I am trying to set up a forwarder to pipe to php script.

The entry in the forwarder list is as follow:

prakash@domain.com to |home5/nadlani1/public_html/parsing.php

The opening of the script is

#!/usr/bin/php -q
<?php

and the beginning of the bounce back message is:

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

  pipe to |/home5/nadlani1/public_html/parsing.php
    generated by prakash@domain.com

The following text was generated during the delivery attempt:

------ pipe to |/home5/nadlani1/public_html/parsing.php
       generated by prakash@domain.com ------

Error in argument 1, char 3: option not found <
Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
       php <file> [args...]
  -a               Run interactively
  -b <address:port>|<port> Bind Path for external FASTCGI Server mode
  -C               Do not chdir to the script's directory
  -c <path>|<file> Look for php.ini file in this directory
  -n               No php.ini file will be used
  -d foo[=bar]     Define INI entry foo with value 'bar'
  -e               Generate extended information for debugger/profiler
  -f <file>        Parse <file>.  Implies `-q'
  -h               This help
  -i               PHP information
  -l               Syntax check only (lint)
  -m               Show compiled in modules
  -q               Quiet-mode.  Suppress HTTP Header output.
  -s               Display colour syntax highlighted source.
  -v               Version number
  -w               Display source with stripped comments and whitespace.
  -z <file>        Load Zend extension <file>.
  -T <count>       Measure execution time of script repeated <count> times.



If I remove the -q I simply get a bounce back with the following header:

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

  pipe to |/home5/nadlani1/public_html/parsing.php
    generated by prakash@domain.com
    local delivery failed

Attached file is parsing.php file for reference.
parsing.php
ASKER CERTIFIED SOLUTION
Avatar of gr8gonzo
gr8gonzo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Starquest321
Starquest321

ASKER

No - not trying to set that up.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hmmm, not sure then. I would make sure you don't have any special characters. If I copy your script and test it locally, it works just fine.

Is that the ACTUAL final command:
pipe to |/home5/nadlani1/public_html/parsing.php
...or are you changing it for the purposes of posting here?
Hi Gr8gonzo,

No special characters in script ..

pipe to |/home5/nadlani1/public_html/parsing.php is the actual path.
My Script is straight forward ..

To check email piping is working or not ..

#!/usr/php/53/usr/bin/php -q
<?php
$final="It worked perfectly";
$fdw = fopen("/home5/nadlani1/public_html/bounce.txt", "w+");
fwrite($fdw, $final);
fclose($fdw);
?>

Using wring some text to text file to see file is executing properly or not..
Does it work when you execute it from the command line?

For example:

echo "Hello world" |/home5/nadlani1/public_html/parsing.php

Also, I'm noticing that your latest bit of code uses a different PHP path for the binary...
Hi Gr8gonzo,

Path is fine no issues with path ::

Only problem with this first line ::

#!/usr/bin/php -q

Error in argument 1, char 3: option not found
Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
       php <file> [args...]
Hi Ray_Paseur,

I tried your solution same result getting error ::

Error in argument 1, char 3: option not found
Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
       php <file> [args...]
Hi Gr8gonzo,

I tried from Command Line :: This time my file is simple just echo statement ::

File is like this ::

#!/usr/bin/php -q
<?php
echo "Prakash";
?>

Used Command Line to see out put ::

echo "Hello world" |/home5/nadlani1/public_html/parsing.php

Same error ::

Error in argument 1, char 3: option not found
Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
       php <file> [args...]
  -a               Run interactively
  -b <address:port>|<port> Bind Path for external FASTCGI Server mode
  -C               Do not chdir to the script's directory
  -c <path>|<file> Look for php.ini file in this directory
  -n               No php.ini file will be used
  -d foo[=bar]     Define INI entry foo with value 'bar'
  -e               Generate extended information for debugger/profiler
  -f <file>        Parse <file>.  Implies `-q'
  -h               This help
  -i               PHP information
  -l               Syntax check only (lint)
  -m               Show compiled in modules
  -q               Quiet-mode.  Suppress HTTP Header output.
  -s               Display colour syntax highlighted source.
  -v               Version number
  -w               Display source with stripped comments and whitespace.
  -z <file>        Load Zend extension <file>.
  -T <count>       Measure execution time of script repeated <count> times.
This seems to show that you have a closing PHP tag.  That is AntiPHPractice #13.  Try removing it - there may be invisible whitespace after it and that may be enough to cause the bounce.
Hi Ray_Paseur,

I tried the way u said .. But it is not working.

The thing is that It is not executing the script :: I think

Any other ways to check Script executing perfectly from Command Line Or not

I tried this way :: echo "Hello world" |/home5/nadlani1/public_html/parsing.php

getting same error.
Is this installed at a professional hosting company?  Do you have cPanel?

If you install the script I posted above (and make the obvious change on line 60) it will send you something when it gets executed.
Hi Ray_Paseur,

I tried the way you said .. But similar error.
Hi Ray_Paseur & Gr8gonzo,

Thanks for your support.

I fixed the issue :;

While adding Forwarders from Cpanel :: added Pipe like this
|/usr/bin/php -q /home5/nadlani1/public_html/parsing.php

"/usr/bin/php -q" part should match to the first line of parsing.php page .. Now it executed perfectly.

Thanks
Strange. It sounds like it was treating your PHP script as if it were a list of commands rather than a PHP script itself. But in most scenarios, that wouldn't happen - if you didn't have executable permissions on the file, then it would just throw an error about permissions, not try to run the file as if it were a bash script or something...

Glad it works now, though.
I don't think you want to have this script in the web root (public_html) directory.  Just a thought...
mmm...why?
You would reduce the risk of accidental (unwanted) execution.  As long as you have a "dummy" script that does not change the data model, it's no problem.  But presumably some day the pipe script will be doing something meaningful -- perhaps storing data, or making data base updates.  If you do not have a public URL, you add a little better security.  Without the URL, the chances that the script was started by something other than an email are greatly reduced.  But if the script has a URL and someone discovers it, your applications becomes a target-rich environment for all kinds of mischief.
I've requested that this question be closed as follows:

Accepted answer: 0 points for Starquest321's comment #a39657183
Assisted answer: 250 points for gr8gonzo's comment #a39656759
Assisted answer: 250 points for Ray_Paseur's comment #a39656791

for the following reason:

/
I didn't do that. . . should be awarded equally to all members who answered.
I didn't do that. . . should be awarded equally to all members who answered.