?
Solved

First PERL script - GetLive

Posted on 2008-10-17
8
Medium Priority
?
719 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

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…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
In this video we show how to create an Accepted Domain 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 >> Ac…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Suggested Courses

770 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