?
Solved

First PERL script - GetLive

Posted on 2008-10-17
8
Medium Priority
?
727 Views
Last Modified: 2013-12-18
I'm a PHP person trying to use the following PERL script, I have never used a PERL script:
http://sourceforge.net/projects/getlive/

I've installed the PHP Perl mod and can run a simple 'hello world' Perl script as:
print "Hello from PHP!<br />";
$perl = new Perl();
$perl->require("test1.pl"); ////print "Hello from perl! "
print "Bye";

I've uploaded the GetLive.pl into "/usr/local/bin/GetLive.pl" and my config file to "home/myuser/.getliveconfig"

My config file is the following:
UserName = myemail
Password = pswd
Domain  = hotmail.com
FetchOnlyUnread = Yes
Folder  = Inbox
Folder  = Junk
MarkRead = Yes
Downloaded = /mail/mydomain.com/hotmail/downloaded
Processor = /usr/sbin/sendmail -i hotmail


However, when I run the following page:
$perl = new Perl();
$perl->require("/usr/local/bin/GetLive.pl --config-file /home/myuser/.getliveconfig");

I get:
Fatal error: Uncaught exception 'PerlException' with message '[perl] require error: Can't locate /usr/local/bin/GetLive.pl --config-file /home/myuser/.getliveconfig in @INC (@INC contains: /usr/lib/perl5/5.8.8/i686-linux /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i686-linux /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl .) at (eval 3) line 1 during global destruction. ' in /home/myuser/public_html/GetLive/index.php:12 Stack trace: #0 /home/myuser/public_html/GetLive/index.php(12): Perl->require('/usr/local/bin/...') #1 {main} thrown in /home/myuser/public_html/GetLive/index.php on line 12

I've never done anything like this before and am trying to get my hotmail mail either forwared to my gmail or at least processed by my mail server. I have root access and cPanel/WHM and have not installed the GetLive RPM, I've just uploaded the files GetLive.pl, SmtpAuthForward.pl, SmtpForward.pl, my config file and the php page that calls the .pl. Once I have this working I was going to build a cron for the php page, unless I can just cron GetLive.pl --config-file /home/myuser/.getliveconfig.

Again, I'm very new to this and have tried many things to get it to work so step by step instructions would be very helpful.
0
Comment
Question by:phper
  • 6
  • 2
8 Comments
 
LVL 39

Accepted Solution

by:
Adam314 earned 2000 total points
ID: 22743197
I think the require method is searching @INC to include the specified program, not taking it as an absolute path.  Try adding the root to @INC:
    $perl = new Perl();
    $perl->eval("use lib '/'");
    $perl->require("/usr/local/bin/GetLive.pl");


Is there a reason you are using PHP to start a perl program - other than you are familiar with PHP?
If not, you could just skip the PHP part.

Do you have shell access?  If so, log in, and try running GetLive.pl (just type "GetLive.pl --config-file /home/myuser/.getliveconfig" without the double-quotes at a prompt).  You will need execute permission.  If you don't have that, then as root:
    chmod 755 /usr/local/bin/GetLive.pl

0
 

Author Comment

by:phper
ID: 22744764
From the SSH I did "GetLive.pl --config-file /home/myuser/.getliveconfig" and I got it to work after some tweeking. Now I can get GetLive.pl to access my hotmail account!

But as of now I can't get it to forward. The manual says to have in the config file to set the Processor as either:
/usr/bin/procmail ///default
SmtpForward.pl  ///Script Provided
SmtpAuthForward.pl ///Script Provided

/usr/sbin/sendmail -i mymailaccount ///Found a website that said use this link below but I can't get his fix for the headers to work
http://aquariusoft.org/~mbscholt/index.php?rantid=573

With the above fix my config had, which resulted in error
Processor = echo -e "\n\n" ; /bin/cat - >> /home/myuser/mail/mydomain.com/forwardacct/:


I've gotten the SmtpForward.pl but the mail is never forwarded.

With SmtpAuthForward.pl it seems to be forwarded but as the emails are forwarded with the headers included and the html as text.  



///SmtpForward.pl which I got to work but the emails have the headers in the message 
 
#!/usr/bin/perl -w
 
use strict;
use Net::SMTP_auth;
 
my $Debug    = 1;
my $Message;
my $Server  = "mail.mydomain.com";
my $Address = "forwardacct\@mydomain.com";
my $From    = "forwardacct\@mydomain.com";
my $AuthType = "login";
my $UserName = "forwardacct\@mydomain.com";	# For the smtp server.
my $Password = "pswrd";	# For the smtp server.
 
# Slurp the message and detect/remove the from.
while (<>) {
  #if (m/^From (.*)$/) {
  #  $From = $1;
  #  next;
  #}
  $Message .= $_;
}
 
my $Smtp = Net::SMTP_auth->new(Host=>$Server,Debug=>$Debug) || 
           die "Could not connect to SMTP server $Server : $!";
 
$Smtp->auth($AuthType,$UserName,$Password);
$Smtp->mail($From);
$Smtp->to($Address);
$Smtp->data();
$Smtp->datasend($Message);
$Smtp->dataend();
$Smtp->quit();

Open in new window

0
 

Author Comment

by:phper
ID: 22744816
Sorry some errors I fixed them:

From the SSH I did "GetLive.pl --config-file /home/myuser/.getliveconfig" and I got it to work after some tweeking. Now I can get GetLive.pl to access my hotmail account!

But as of now I can't get it to forward. The manual says to have in the config file to set the Processor as either:
1) /usr/bin/procmail ///default which results in error:
Sending mail to '/usr/bin/procmail'.
Can't exec "/usr/bin/procmail": No such file or directory at /usr/local/bin/GetLive.pl line 1168.
print() on closed filehandle PR at /usr/local/bin/GetLive.pl line 1169.
GetLive died with message: 'Sending mail to '/usr/bin/procmail' did not succeed. See error log. at /usr/local/bin/GetLive.pl line 1170.

2) SmtpForward.pl  ///Script Provided
I've gotten the SmtpForward.pl to work but the mail is never forwarded.

3) SmtpAuthForward.pl ///Script Provided
With SmtpAuthForward.pl it seems to be forwarded but as the emails are forwarded with the headers included and the html as text.  

4) /usr/sbin/sendmail -i mymailaccount ///Found a website that said use this link below but I can't get his fix for the headers to work
http://aquariusoft.org/~mbscholt/index.php?rantid=573

With the above fix my config had
Processor = echo -e "\n\n" ; /bin/cat - >> /home/myuser/mail/mydomain.com/forwardacct/

Which resulted in error:
Sending mail to 'echo -e "\n\n" ; /bin/cat - >> /home/myuser/mail/mydomain.com/forwardacct/.



sh: /home/myuser/mail/mydomain.com/forwardacct/: Is a directory
GetLive died with message: 'Sending mail to 'echo -e "\n\n" ; /bin/cat - >> /home/myuser/mail/mydomain.com/forwardacct/' did not succeed. See error log. at /usr/local/bin/GetLive.pl line 1170.






0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 39

Expert Comment

by:Adam314
ID: 22745231
Do you have access to sendmail, usually one of these:
    /bin/sendmail
    /usr/bin/sendmail
    /usr/sbin/sendmail
0
 

Author Comment

by:phper
ID: 22748995
I found it in:
/usr/sbin/sendmail

What next?
0
 

Author Comment

by:phper
ID: 22748998
Just did whereis sendmail and got:
sendmail: /usr/sbin/sendmail /usr/lib/sendmail
0
 

Author Comment

by:phper
ID: 22749208
I've suscessfully used in the config:
Processor = /usr/sbin/sendmail forwardacct\@mydomain.com

I'm setting up the cron now and will let you know but I think we have it.
0
 

Author Closing Comment

by:phper
ID: 31507217
Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Steps to fix “Unable to mount database. (hr=0x80004005, ec=1108)”.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question