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
PHPScripting LanguagesWeb Languages and Standards

Avatar of undefined
Last Comment
Starquest321

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
gr8gonzo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Starquest321

ASKER
No - not trying to set that up.
SOLUTION
Ray Paseur

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
gr8gonzo

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?
Starquest321

ASKER
Hi Gr8gonzo,

No special characters in script ..

pipe to |/home5/nadlani1/public_html/parsing.php is the actual path.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Starquest321

ASKER
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..
gr8gonzo

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...
Starquest321

ASKER
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...]
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Starquest321

ASKER
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...]
Starquest321

ASKER
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.
Ray Paseur

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.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Starquest321

ASKER
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.
Ray Paseur

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.
Starquest321

ASKER
Hi Ray_Paseur,

I tried the way you said .. But similar error.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Starquest321

ASKER
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
gr8gonzo

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.
Ray Paseur

I don't think you want to have this script in the web root (public_html) directory.  Just a thought...
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Starquest321

ASKER
mmm...why?
Ray Paseur

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.
Starquest321

ASKER
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:

/
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Starquest321

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

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