Results 1 to 2 of 2
Discuss Perl error running IMAPfilter.pl script at the Free Toolchain Software (Cydia App's) - Hackint0sh.org; I got the following error.... # # perl /usr/bin/imapfilter.pl Not a CODE reference at /usr/bin/imapfilter.pl ...
  1. #1
    Rookie Array

    Join Date
    Sep 2007
    Posts
    10
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default Perl error running IMAPfilter.pl script

    I got the following error....

    #
    # perl /usr/bin/imapfilter.pl
    Not a CODE reference at /usr/bin/imapfilter.pl line 22.
    BEGIN failed--compilation aborted.
    #

    From the script attached... the line is question is just 'use warnings;' ... I know little about perl, but it seems to be a standard module, so I am guess an environment variable may be wrong? - as I have installed perl and the BSD subsystem from the 'Installer.app'.



  2. #2
    Rookie Array

    Join Date
    Sep 2007
    Posts
    10
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    Sorry, could not put script as attachment.... please find below...

    #! /usr/bin/perl

    # Copyright (C) 2004-2006 Lars Eggert <lars.eggert@gmx.net>
    # All rights reserved.
    #
    # Redistribution and use in source and binary forms are permitted
    # provided that the above copyright notice and this paragraph are
    # duplicated in all such forms and that any documentation,
    # advertising materials, and other materials related to such
    # distribution and use acknowledge that the software was developed
    # by the author. The name of the author may not be used to endorse
    # or promote products derived from this software without specific
    # prior written permission.
    #
    # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
    # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
    # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    # PURPOSE.

    # $Id: imapfilter.pl,v 1.12 2006/08/21 16:52:10 eggert Exp $

    use warnings;
    use strict;
    #use lib "$ARGV[0]/Contents/Resources";

    #use IO::Socket::SSL;
    #use IO::Select;
    use Net::hostent;
    use POSIX ();
    use Getopt::Long;
    use FindBin;


    # these need to be perl regexps matching the IMAP folders to omit
    my @omit = ("Public Folders");

    STDOUT->autoflush(1);
    STDERR->autoflush(1);

    # Process options
    my %opt = ( );
    if (GetOptions(\%opt, "help", "verbose") == 0 or $opt{h}) {
    print <<STOP;

    Usage: $FindBin::Script [-help] [-verbose]

    Where: -help print this message
    -verbose do not become a daemon and be more verbose

    STOP
    exit;
    }

    # Daemonize!
    sub daemon () {
    sub _fork {
    if (defined (my $pid = fork)) { return $pid; }
    else { die "cannot fork: $!"; }
    }

    # fork and exit parent
    if (_fork) { exit 0; }

    # detach ourselves from the terminal
    POSIX::setsid or die "cannot detach from controlling terminal";

    # prevent possibility of acquiring a controlling terminal
    $SIG{'HUP'} = 'IGNORE';
    if (_fork) { exit 0; }

    # change working directory
    chdir "/";

    # clear file creation mask
    umask 0;

    # close open file descriptors
    foreach my $i (0..POSIX::sysconf(&POSIX::_SC_OPEN_MAX)) { POSIX::close $i; }

    # Reopen stderr, stdout, stdin to /dev/null
    open STDIN, "+>/dev/null";
    open STDOUT, "| /usr/bin/logger -p user.notice";
    open STDERR, "+>&STDOUT";
    STDOUT->autoflush(1);
    STDERR->autoflush(1);
    }

    my $client = "localhost:1143"; # 143 = imap - use different port
    my $server = "exchange.lse.ac.uk:143";
    my %mua;
    my %imap;
    my %data;
    daemon unless $opt{verbose};
    my $inbound = new IO::Socket::INET(LocalHost => $client,
    Listen => 50,
    ReuseAddr => 1);
    die "cannot open proxy socket on $client - not root?" unless $inbound;
    print "$FindBin::Script listening on $client\n" if $opt{verbose};

    my $select = IO::Select->new($inbound);
    while (1) {
    my @ready = $select->can_read(10);
    foreach my $fd (@ready) {

    # a MUA is opening a new connection to us, open relay to server
    if ($fd == $inbound) {
    my $new_mua = $inbound->accept;
    print "$FindBin::Script connected to MUA\n" if $opt{verbose};
    my $new_imap;
    if ($server =~ /:993/) {
    $new_imap = new IO::Socket::SSL($server);
    } else {
    $new_imap = new IO::Socket::INET($server);
    }
    unless (defined $new_imap) {
    $new_mua->close;
    print "$FindBin::Script cannot connect to $server\n" if $opt{verbose};
    } else {
    $select->add($new_mua, $new_imap);
    $mua{$new_mua} = $new_imap;
    $imap{$new_imap} = $new_mua;
    print "$FindBin::Script connected to $server\n" if $opt{verbose};
    }
    }

    # the IMAP server is sending something to the MUA, filter and relay
    if ($fd and exists $imap{$fd}) {
    while(1) {
    $fd->blocking(0);
    my $new_data;
    my $result = sysread $fd, $new_data, 8192;
    if (not defined $result) {
    last if not defined $data{$fd};
    print "$FindBin::Script sysread $!\n" if $opt{verbose} and $! != 35;

    foreach my $pattern (@omit) {
    $data{$fd} =~
    s/^\* LIST (\([^)]*\))? "[^"]" "?$pattern[^\r\n]*"?\r\n//gm;
    }

    $imap{$fd}->blocking(1);
    my $r = syswrite $imap{$fd}, $data{$fd};
    if ($opt{verbose} and $r != length $data{$fd}) {
    print "$FindBin::Script only wrote $r/". length $data{$fd} ." bytes to $server\n";
    }
    delete $data{$fd};
    last;

    } elsif ($result > 0) {
    $data{$fd} .= $new_data;

    } elsif ($result == 0) {
    print "$FindBin::Script sysread $result\n" if $opt{verbose};

    # EOF, close the connections
    $select->remove($fd, $imap{$fd});
    $imap{$fd}->close;
    delete $imap{$fd};
    $fd->close;
    $fd = undef;
    print "$FindBin::Script closed connection with $server\n" if $opt{verbose};
    last;
    }
    }
    }

    # the MUA is sending something to the IMAP server, just relay
    if ($fd and exists $mua{$fd}) {
    while (1) {
    $fd->blocking(0);
    my $result = sysread $fd, $_, 8192;
    if (not defined $result) {
    last;
    } elsif ($result > 0) {
    $mua{$fd}->blocking(1);
    my $r = syswrite $mua{$fd}, $_;
    if ($opt{verbose} and $r != length $_) {
    print "$FindBin::Script only wrote $r/". length $_ ." bytes to MUA\n";
    }
    } elsif ($result == 0) {
    # EOF, close the connections
    $select->remove($fd, $mua{$fd});
    $mua{$fd}->close;
    delete $mua{$fd};
    $fd->close;
    $fd = undef;
    print "$FindBin::Script closed connection with MUA\n" if $opt{verbose};
    last;
    }
    }
    }
    }
    }
    $inbound->close;
    die "$FindBin::Script terminated (should never happen)";

 

 

Similar Threads

  1. stuck on Running script HELP!!!!!
    By chrisjeymy1 in forum Installation
    Replies: 4
    Last Post: 09-11-2010, 09:42 PM
  2. problem - running script from springboard
    By Luki14 in forum Free Toolchain Software (Cydia App's)
    Replies: 3
    Last Post: 10-02-2009, 11:17 PM
  3. output script running from springboard
    By spitphire in forum Free Toolchain Software (Cydia App's)
    Replies: 2
    Last Post: 10-01-2009, 11:50 AM
  4. Running a script for a incoming call
    By t0pcat in forum General
    Replies: 2
    Last Post: 10-19-2007, 09:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBulletin®
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
Search Engine Friendly URLs by vBSEO
(c) 2006-2012 Hackint0sh.org
All times are GMT +2. The time now is 06:20 PM.
twitter, follow us!