View previous topic :: View next topic |
Author |
Message |
niedzwiedz Tux's lil' helper
Joined: 05 Jun 2006 Posts: 93 Location: BP
|
Posted: Sat Oct 07, 2006 7:31 pm Post subject: problem with gmail.pl script and crontab? |
|
|
Hi everybody.
I downloaded scrpt that should check my gmail box and list messages in the conky...
Some way it's not working
Code: |
#!/usr/bin/perl
# Put this in ~/.gmail/ and use "crontab -e" to add something like
# "* * * * * ~/.gmail/gmail.pl > /dev/null" to run it every minute.
# ${exec cat ~/.gmail/.gmail_top} shows your inbox in Conky.
# Note that this was intended to be used with Gmail or any other
# ssl-enabled pop3 server.
# beginning of configuration
# pop3 host
$pop_host = "pop.gmail.com";
# pop3 username (for Gmail, I didn't have to put @gmail.com at the end)
$pop_user = "username";
# pop3 password
$pop_pass = "password";
# ssl port number (995 is what Gmail uses)
$ssl_port = "995";
# ssl protocol
$ssl_prot = "tcp";
# number of emails to show
$dis_numb = "6";
# end of configuration
use Mail::POP3Client;
use IO::Socket::SSL;
my $socket = IO::Socket::SSL->new( PeerAddr => $pop_host,
PeerPort => $ssl_port,
Proto => $ssl_prot);
my $pop = Mail::POP3Client->new();
$pop->User($pop_user);
$pop->Pass($pop_pass);
$pop->Socket($socket);
$pop->Connect();
$msg_count = $pop->Count();
for ($i = $msg_count, $j = 0; $i >= $msg_count-($dis_numb-1); $i--, $j++) {
foreach ( $pop->Head( $i ) ) {
#/^(From|Subject):\s+/i and print $_, "\n";
if ($_ =~ m/^From:/) {
($from) = ($_ =~ m#^From: .*<(.*)>#);
$from = substr($from, 0, 30);
$out .= "$j = $from\n";
}
}
#chop $out;
`echo -e "$out"> root/.gmail/.gmail_top`;
}
$pop->Close();
|
i replaced login and password, when i run conky i get something like : cat: /root/.gmail/.gmail_top file doesn't exist.
I did everything that is written at the begiining(adding to crontab etc.) _________________ Blogoslawieni ci ktorzy nie majac nic do powiedzenia nie ubieraja tego faktu w slowa.
www.howstuffworks.com |
|
Back to top |
|
|
Syque Tux's lil' helper
Joined: 15 Aug 2004 Posts: 110
|
Posted: Sat Oct 07, 2006 9:19 pm Post subject: |
|
|
I'm assuming you're running this from your personal crontab.
Also, the mail file is supposed to be ~/.gmail/.gmail_top, but near the end the script reads Code: | `echo -e "$out"> root/.gmail/.gmail_top`; | when it should read Code: | `echo -e "$out"> ~/.gmail/.gmail_top`; |
|
|
Back to top |
|
|
niedzwiedz Tux's lil' helper
Joined: 05 Jun 2006 Posts: 93 Location: BP
|
Posted: Sat Oct 07, 2006 9:50 pm Post subject: |
|
|
changin /root/.gmail to ~/.gmail doesn't make it working _________________ Blogoslawieni ci ktorzy nie majac nic do powiedzenia nie ubieraja tego faktu w slowa.
www.howstuffworks.com |
|
Back to top |
|
|
Syque Tux's lil' helper
Joined: 15 Aug 2004 Posts: 110
|
Posted: Sat Oct 07, 2006 10:06 pm Post subject: |
|
|
I'm out of bright ideas so I'll try basic questions. Does the folder ~/.gmail exist? Does the file ~/.gmail/gmail_top exist? Did you remember to make the script executable? (chmod o+x ~/.gmail/gmail.pl) Are you a member of the cron group? Did you remember to change the conky configuration to look for ~/.gmail/.gmail_top instead of the previous /root/.gmail/.gmail_top? Does the script work if you run it by hand instead of from crontab? |
|
Back to top |
|
|
niedzwiedz Tux's lil' helper
Joined: 05 Jun 2006 Posts: 93 Location: BP
|
Posted: Sat Oct 07, 2006 11:46 pm Post subject: |
|
|
ok, i created ~/.gmail/.gmail_top file because it didn't exist, but when i run conky the file remians empty:(. How to run this script by hand? All directories and files exist and gmail.pl is executable. _________________ Blogoslawieni ci ktorzy nie majac nic do powiedzenia nie ubieraja tego faktu w slowa.
www.howstuffworks.com |
|
Back to top |
|
|
Syque Tux's lil' helper
Joined: 15 Aug 2004 Posts: 110
|
Posted: Sun Oct 08, 2006 12:06 am Post subject: |
|
|
Type to run the script. |
|
Back to top |
|
|
niedzwiedz Tux's lil' helper
Joined: 05 Jun 2006 Posts: 93 Location: BP
|
Posted: Sun Oct 08, 2006 9:27 am Post subject: |
|
|
ok, when i run it by hand i get: Code: |
Can't locate Mail/POP3Client.pm in @INC (@INC contains: /etc/perl /usr/lib/perl5/vendor_perl/5.8.8/i686-linux /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.7/i686-linux /usr/lib/perl5/vendor_perl /usr/lib/perl5/site_perl/5.8.8/i686-linux /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/5.8.8/i686-linux /usr/lib/perl5/5.8.8 /usr/local/lib/site_perl .) at /root/.gmail/gmail.pl line 31.
BEGIN failed--compilation aborted at /root/.gmail/gmail.pl line 31.
|
_________________ Blogoslawieni ci ktorzy nie majac nic do powiedzenia nie ubieraja tego faktu w slowa.
www.howstuffworks.com |
|
Back to top |
|
|
Syque Tux's lil' helper
Joined: 15 Aug 2004 Posts: 110
|
Posted: Sun Oct 08, 2006 12:50 pm Post subject: |
|
|
You need to get the Mail::POP3Client module from the CPAN site, a repository for Perl modules. If the direct link doesn't work, try going to http://www.cpan.org/, click on 'Perl Modules', then 'name', then 'Mail', and then download Mail-POP3Client-2.17.tar.gz.
Then you'll need to copy that to root's directory, as root and do Code: | # tar -xzvof Mail-POP3Client-2.17.tar.gz
# cd Mail-POP3Client-2.17
# perl Makefile.PL
# make
# make test
# make install | to install the necessary module.
Reading the README file in that directory is also a good idea, as usual, to make sure I haven't screwed up these commands.
You may to need to do something similar to get the other module called from your script: IO::Socket::SSL. (The file name to download this time will be IO-Socket-SSL-1.01.tar.gz in the IO folder of the modules list. |
|
Back to top |
|
|
niedzwiedz Tux's lil' helper
Joined: 05 Jun 2006 Posts: 93 Location: BP
|
Posted: Mon Oct 09, 2006 10:59 pm Post subject: |
|
|
ok, here we come
I installed POP3 client module succesfully, but when i try to install IO socket make test returns :
Code: | Failed Test Stat Wstat Total Fail Failed List of Failed
-------------------------------------------------------------------------------
t/01loadmodule.t 2 512 4 8 200.00% 1-4
t/02settings.t 2 512 ?? ?? % ??
t/cert_no_file.t 2 512 ?? ?? % ??
t/compatibility.t 2 512 ?? ?? % ??
t/core.t 2 512 ?? ?? % ??
t/dhe.t 2 512 ?? ?? % ??
t/nonblock.t 2 512 ?? ?? % ??
t/readline.t 2 512 ?? ?? % ??
t/sessions.t 2 512 ?? ?? % ??
t/startssl.t 2 512 ?? ?? % ??
t/sysread_write.t 2 512 ?? ?? % ??
Failed 11/11 test scripts, 0.00% okay. 4/4 subtests failed, 0.00% okay.
make: *** [test_dynamic] Error 2
|
oh, i've found something more:
Code: | Can't locate Net/SSLeay.pm |
i tried to install Crypt-SSLeay-0.51 but:
Code: | SSLeay.c:399: error: `ctx' undeclared (first use in this function)
SSLeay.c:400: warning: ISO C90 forbids mixed declarations and code
SSLeay.xs:235: error: `SSL' undeclared (first use in this function)
SSLeay.xs:235: error: `ssl' undeclared (first use in this function)
SSLeay.c:404: error: `RETVAL' undeclared (first use in this function)
SSLeay.c:408: error: parse error before ')' token
SSLeay.c: In function `XS_Crypt__SSLeay__Conn_free':
SSLeay.c:454: error: `SSL' undeclared (first use in this function)
SSLeay.c:454: error: `ssl' undeclared (first use in this function)
SSLeay.c:458: error: parse error before ')' token
SSLeay.c: In function `XS_Crypt__SSLeay__Conn_set_fd':
SSLeay.c:476: error: `SSL' undeclared (first use in this function)
SSLeay.c:476: error: `ssl' undeclared (first use in this function)
SSLeay.c:477: warning: ISO C90 forbids mixed declarations and code
SSLeay.c:483: error: parse error before ')' token
SSLeay.c: In function `XS_Crypt__SSLeay__Conn_connect':
SSLeay.c:502: error: `SSL' undeclared (first use in this function)
SSLeay.c:502: error: `ssl' undeclared (first use in this function)
SSLeay.c:503: warning: ISO C90 forbids mixed declarations and code
SSLeay.c:508: error: parse error before ')' token
SSLeay.c: In function `XS_Crypt__SSLeay__Conn_accept':
SSLeay.c:527: error: `SSL' undeclared (first use in this function)
SSLeay.c:527: error: `ssl' undeclared (first use in this function)
SSLeay.c:528: warning: ISO C90 forbids mixed declarations and code
SSLeay.c:533: error: parse error before ')' token
SSLeay.c: In function `XS_Crypt__SSLeay__Conn_write':
SSLeay.c:552: error: `SSL' undeclared (first use in this function)
SSLeay.c:552: error: `ssl' undeclared (first use in this function)
SSLeay.xs:287: warning: ISO C90 forbids mixed declarations and code
SSLeay.c:564: error: parse error before ')' token
SSLeay.c: In function `XS_Crypt__SSLeay__Conn_read':
SSLeay.c:606: error: `SSL' undeclared (first use in this function)
SSLeay.c:606: error: `ssl' undeclared (first use in this function)
SSLeay.c:607: warning: ISO C90 forbids mixed declarations and code
SSLeay.c:619: error: parse error before ')' token
SSLeay.c: In function `XS_Crypt__SSLeay__Conn_get_peer_certificate':
SSLeay.c:672: error: `SSL' undeclared (first use in this function)
SSLeay.c:672: error: `ssl' undeclared (first use in this function)
SSLeay.c:673: error: `X509' undeclared (first use in this function)
SSLeay.c:673: error: `RETVAL' undeclared (first use in this function)
SSLeay.c:677: error: parse error before ')' token
SSLeay.c: In function `XS_Crypt__SSLeay__Conn_get_verify_result':
SSLeay.c:697: error: `SSL' undeclared (first use in this function)
SSLeay.c:697: error: `ssl' undeclared (first use in this function)
SSLeay.c:698: warning: ISO C90 forbids mixed declarations and code
SSLeay.c:702: error: parse error before ')' token
SSLeay.xs:377: error: `X509_V_OK' undeclared (first use in this function)
SSLeay.c: In function `XS_Crypt__SSLeay__Conn_get_shared_ciphers':
SSLeay.c:723: error: `SSL' undeclared (first use in this function)
SSLeay.c:723: error: `ssl' undeclared (first use in this function)
SSLeay.xs:386: warning: ISO C90 forbids mixed declarations and code
SSLeay.c:732: error: parse error before ')' token
SSLeay.xs:388: warning: assignment makes pointer from integer without a cast
SSLeay.c: In function `XS_Crypt__SSLeay__Conn_get_cipher':
SSLeay.c:752: error: `SSL' undeclared (first use in this function)
SSLeay.c:752: error: `ssl' undeclared (first use in this function)
SSLeay.c:753: warning: ISO C90 forbids mixed declarations and code
SSLeay.c:758: error: parse error before ')' token
SSLeay.c: In function `XS_Crypt__SSLeay__X509_free':
SSLeay.c:778: error: `X509' undeclared (first use in this function)
SSLeay.c:778: error: `cert' undeclared (first use in this function)
SSLeay.c:782: error: parse error before ')' token
SSLeay.c: In function `XS_Crypt__SSLeay__X509_subject_name':
SSLeay.c:800: error: `X509' undeclared (first use in this function)
SSLeay.c:800: error: `cert' undeclared (first use in this function)
SSLeay.xs:410: warning: ISO C90 forbids mixed declarations and code
SSLeay.c:808: error: parse error before ')' token
SSLeay.xs:412: warning: assignment makes pointer from integer without a cast
SSLeay.c: In function `XS_Crypt__SSLeay__X509_issuer_name':
SSLeay.c:831: error: `X509' undeclared (first use in this function)
SSLeay.c:831: error: `cert' undeclared (first use in this function)
SSLeay.xs:422: warning: ISO C90 forbids mixed declarations and code
SSLeay.c:839: error: parse error before ')' token
SSLeay.xs:424: warning: assignment makes pointer from integer without a cast
SSLeay.c: In function `XS_Crypt__SSLeay__X509_get_notBeforeString':
SSLeay.c:862: error: `X509' undeclared (first use in this function)
SSLeay.c:862: error: `cert' undeclared (first use in this function)
SSLeay.c:863: warning: ISO C90 forbids mixed declarations and code
SSLeay.c:868: error: parse error before ')' token
SSLeay.xs:434: error: invalid type argument of `->'
SSLeay.c: In function `XS_Crypt__SSLeay__X509_get_notAfterString':
SSLeay.c:888: error: `X509' undeclared (first use in this function)
SSLeay.c:888: error: `cert' undeclared (first use in this function)
SSLeay.c:889: warning: ISO C90 forbids mixed declarations and code
SSLeay.c:894: error: parse error before ')' token
SSLeay.xs:442: error: invalid type argument of `->'
make: *** [SSLeay.o] Error 1
|
_________________ Blogoslawieni ci ktorzy nie majac nic do powiedzenia nie ubieraja tego faktu w slowa.
www.howstuffworks.com |
|
Back to top |
|
|
Syque Tux's lil' helper
Joined: 15 Aug 2004 Posts: 110
|
Posted: Tue Oct 10, 2006 12:31 pm Post subject: |
|
|
The IO::Socket::SSL module is in portage, so try "emerge -v IO-Socket-SSL" to install that module rather than do it manually. |
|
Back to top |
|
|
niedzwiedz Tux's lil' helper
Joined: 05 Jun 2006 Posts: 93 Location: BP
|
Posted: Tue Oct 10, 2006 7:55 pm Post subject: |
|
|
Well, now the script is executing without any errors, but unfortunattely .gmail_top file is still empty, despite the script has been executed _________________ Blogoslawieni ci ktorzy nie majac nic do powiedzenia nie ubieraja tego faktu w slowa.
www.howstuffworks.com |
|
Back to top |
|
|
Syque Tux's lil' helper
Joined: 15 Aug 2004 Posts: 110
|
Posted: Tue Oct 10, 2006 9:10 pm Post subject: |
|
|
I think the script is ok, so maybe the problem is with gmail. I don't have a gmail account, but looking at their pop3 instructions, you first need to set up your account to allow pop3 access.
EDIT: Also, according to gmail's pop3 client instructions, your user name needs to include "@gmail.com" |
|
Back to top |
|
|
|