Hi guys,
I have a weird issue I was wondering if anyone had any input on. I found and adapted a perl script to grab attachments from an email account into a directory served by an ftp account. The problem is that while the script works from a command shell for either user and works in Scheduled Tasks under my login (which is an administrator with log on as a batch job and log on as a service both enabled) it won't run under the job user account (which at this point is also an administrator with the same user rights in both the filesystem and local policy).
Here's the script, you may recognize it if you search for it, I didn't change much:
#!/usr/bin/perl use Carp; use Email::MIME; use File::Basename; use warnings; #use Net::POP3; use Net::SSLGlue::POP3; my $server = '...'; my $receiveruname = '...'; my $password = '...'; my $attachment_dir = '...'; my $pop = Net::POP3->new($server, SSL => 1, SSL_verify_mode => 0) || die "Couldn't connect to the server $!.\n\n"; #$pop->starttls( SSL_verify_mode => 0) || die "Can't perform starttls: $!"; #my $pop = Net::POP3->new($server); #croak "Couldn't connect to the server.\n\n" unless $pop; my $num_messages = $pop->login( $receiveruname, $password ); croak "Connection trouble network password user ..." unless defined $num_messages; for my $i ( 1 .. $num_messages ) { my $aref = $pop->get($i); my $em = Email::MIME->new( join '', @$aref ); for ( my @parts = $em->parts ) { print $_->content_type, "\n"; next unless $_->content_type =~ m(^application/vnd.ms-excel)i; my $filename = basename( $_->filename || '' ); my $basefilename = $filename || 'UNNAMED'; my $cnt = 0; while ( -e "$attachment_dir/$filename" ) { my ( $d, $m, $y ) = (localtime)[ 3 .. 5 ]; $filename = sprintf( "%s_%04d%02d%02d_%04d", $basefilename, $y + 1900, $m + 1, $d, ++$cnt ); } open my $fh, ">", "$attachment_dir/$filename" or croak $!; binmode $fh; print $fh $_->body; $pop->delete($i); } } $pop->quit;
I replaced the values for the variables at the beginning with ..., suffice to say they're set properly.
Literally everything is identical in the task scheduler and script, I just changed the user it's running under to my login and it works whether I'm logged in or not, though it would return 0x2 if run under the job user, even if I rdp into the server using the job user logon (normally I have the job user unable to rdp in, but I'm getting frustrated now)
I'm using strawberry perl and used cpan to install the Email::MIME and Net::SSLGlue modules.
I have it running under my user right now but that means I have to update it every month when i change my passwords. Can anyone think of any reason at all that it wouldn't run under the job user at this point?