Solved

First PERL script - GetLive

Posted on 2008-10-17
8
708 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 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 39

Expert Comment

by:Adam314
Comment Utility
Do you have access to sendmail, usually one of these:
    /bin/sendmail
    /usr/bin/sendmail
    /usr/sbin/sendmail
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:phper
Comment Utility
I found it in:
/usr/sbin/sendmail

What next?
0
 

Author Comment

by:phper
Comment Utility
Just did whereis sendmail and got:
sendmail: /usr/sbin/sendmail /usr/lib/sendmail
0
 

Author Comment

by:phper
Comment Utility
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
Comment Utility
Thanks!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Import PST to Exchange using Power Shell new-mailboximportrequest command, you can simply import the PST file into Exchange mailbox or archived. To know How to import PST into Exchange  2013 read the complete article.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now