Jump to content

Recommended Posts

I am running Debian 5.0 with latest updates, but I seem to be having problems when exciting a php script via Debian's CLI.

 

It seems that Debian Lenny changed #!/usr/bin/php -q; as in the /usr/bin/php directory no longer exists.  What is the proper way to add the hashbang to the top of the php script in debian?

 

I have php5 as well as php5-cli installed.

 

Thanks in advance!

owner

Link to comment
https://forums.phpfreaks.com/topic/191699-execute-php-file/
Share on other sites

PHP is in the same location it always was in Debian. /usr/bin/php and its a file, not a directory.

 

If /usr/bin/php does not exist then php 's cli is not installed. At least not via apt anyway.

 

The proper way however to add a shebang is to use the env command.

 

#!/usr/bin/env php

 

This should make your script compatible across distributions.

Link to comment
https://forums.phpfreaks.com/topic/191699-execute-php-file/#findComment-1010424
Share on other sites

Ok I added that to the top of my php file and then added <?php right below, but it seems that the script still isn't executing properly (the script doesn't fully execute, it just hangs and I have to press control+c to break out of it) when called from Debian's CLI.

 

What I am trying to do is to pipe an incoming email to the php file.  Am I going about this wrong?  Here is what command I am using to forward the email: |/var/www/mail/forward.php

 

Thank you for the reply thorpe :)

owner

Link to comment
https://forums.phpfreaks.com/topic/191699-execute-php-file/#findComment-1010431
Share on other sites

Right now I have it running wide open lol -rwxrwxrwx

 

This is my first time trying to pipe something to an email.  Is this command even correct for piping the mail? |/var/www/mail/forward.php?  Some sites show I need to point it to that php directory that I don't seem to have....

 

Thanks for helping,

owner

Link to comment
https://forums.phpfreaks.com/topic/191699-execute-php-file/#findComment-1010439
Share on other sites

Postfix.  Here is a guide that I referenced when setting up my email (I know it is outdated, just used it as a reference): http://workaround.org/ispmail/etch

 

I can send and receive email fine via telnet as well as outlook or squirrelmail.

 

Here is what is in my php file that I am using for testing:

#!/usr/bin/env php
<?php
// start output buffering
ob_start();

// get your email from stdin
$email = file_get_contents('php://stdin');

// do stuff

// log your email to logfile
/*
$fp = fopen('log.txt', 'r');
if ($fp) {
fwrite($fp, $email, strlen($email));
fclose();
}*/

// or send you a copy
mail('myemail@********.com', 'email received', $email, 'from: mailman@********..com');

// clean the output
ob_end_flush();
?>

Link to comment
https://forums.phpfreaks.com/topic/191699-execute-php-file/#findComment-1010451
Share on other sites

Update: Here is a log from the mail.log file.  Looks like I have done something wrong bigtime...

 

Feb 10 20:20:14 ******** postfix/pipe[30361]: 63941EC086: to=<|/var/www/mail/forward.php@********.com>, orig_to=<test@********.com>, relay=dovecot, delay=0.05, delays=0.01/0.03/0/0.01, dsn=2.0.0, status=sent (delivered via dovecot service)

Feb 10 20:20:14 ******** postfix/qmgr[30344]: 63941EC086: removed

Link to comment
https://forums.phpfreaks.com/topic/191699-execute-php-file/#findComment-1010515
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.