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
Solved

First PERL script - GetLive

Posted on 2008-10-17
8
713 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
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In this video we show how to create an Address List 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 Organization >> Ad…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

829 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