LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-12-2019, 10:31 AM   #1
vinmansbrew
Member
 
Registered: Feb 2016
Posts: 64

Rep: Reputation: Disabled
IO::Socket::INET: connect: Connection refused at ./newpeople.pl line 104, <DATA> line 522.


So, I have a series of scripts(I didn't write them, but they are perl) and they currently check against an ldap server to update the names. I need to move to a new ldap server, but when I try to run the script,I receive the error: IO::Socket::INET: connect: Connection refused at ./newstudents.pl line 104, <DATA> line 522.

Here is the script, I tried to make sure formatting was kept.
Code:
#!/usr/bin/perl -w

use strict;
use Net::LDAP;
use Time::Piece;

if ($#ARGV < 0)
{
  print STDERR "Usage: ./newpeople.pl pwd\n";
  exit 1;
}

my $host = "ldapsource";
my $bindcred = $ARGV[0];
my $binddn = "cn=Ldap Manage";
my $basedn = "ou=People,dc=straw,dc=com";
my $dateout = Time::Piece->new->strftime('%Y%m%d');
my $infile = "output/$dateout/newpeople.list";

open(OUTFILE, ">", $infile) or die("Can't open $infile.clean for output");

my $ldap = Net::LDAP->new($host, timeout=>2) ||
  SYSerror("New", "Couldn't connect to $host");
my $mesg = $ldap->bind("$binddn", password=>"$bindcred");
if ($mesg->is_error) {LDAPerror("Bind", $mesg);}

my $result = $ldap->search(base=>"$basedn", scope=>"sub",
  filter=>"(&(!(nsAccountLock=*))(strawEmpRole=NEWPEOPLE))",
  attrs=>["mail","cn"]);
if ($result->is_error) {LDAPerror("Search", $result);}

my @entries = $result->entries;


my $mExcludingFile = "excludes/new-people.txt";
my $includingFile = "includes/new-people.txt";
my @mArray = ();
my $mLine;
my $mCountAll = 0;
my $mCountOrig = 0;
my $mCountAdd = 0;
my $mCountDel = 0;

open(ROFILE, "<", $mExcludingFile) or die("Can't open $mExcludingFile exception file!");
while(<ROFILE>) {
  push(@mArray, $_);
}         
close(ROFILE);

my $mArrayNow;
my $entry;

foreach $entry(@entries) {
      my $name = $entry->get_value("cn");
      my $email = $entry->get_value("mail");
      my $mLineNow = "$email $name\n";
      my $mOkay = 1; 
      $mCountOrig++;

      foreach $mArrayNow (@mArray) {
        if ($mLineNow eq $mArrayNow) {                           
	  $mOkay = 0;
        }

      }   

      if ($mOkay == 1) {
        print OUTFILE $mLineNow;
      } else {
		$mCountDel++;
      }
}


flock(OUTFILE, 8);
close(OUTFILE);
open(OUTFILE, ">>", $infile);
open(EXCEPTF, "<", $includingFile) or die("Can't open $includingFile exception file!");
while(<EXCEPTF>) {
        print OUTFILE $_;
        $mCountAdd++;
}
flock(OUTFILE, 8);
close(OUTFILE);
close(EXCEPTF);


$mCountAll = $mCountOrig + $mCountAdd - $mCountDel;

print "Ok.. Generated ".$mCountAll." (".$mCountOrig." + ".$mCountAdd. " - ".$mCountDel.")\n";

sub LDAPerror
{
  my ($from, $mesg) = @_;
  print "Error: " . $mesg->code . " (" . $mesg->error_name . ")\n";
  print $mesg->error_text . "\n";
}

sub SYSerror
{
  my ($from, $mesg) = @_;
  print "Error: $mesg\n";
  print "Source: $from\n";
  die "$@";
}
 
Old 08-12-2019, 11:23 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,803

Rep: Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287
Networking problem. Most likely a firewall.
 
Old 08-12-2019, 11:31 AM   #3
vinmansbrew
Member
 
Registered: Feb 2016
Posts: 64

Original Poster
Rep: Reputation: Disabled
Hmm, that's kinda what I thinking. I figured I'd check as some looking here showed that other people had script problems, and I wanted to cover that base.

I'll see what the network guy finds. Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
is there a way to get /etc/rc.d/rc.inet? to use a different rc.inet.conf rob.rice Slackware 4 02-03-2017 03:39 PM
Unable to connect to Upstart: Failed to connect to socket /com/Ubuntu/upstart: Connection refused. audduck Linux - Newbie 0 08-07-2016 09:45 PM
postfix/smtpd: warning: connect to Milter service inet: Connection refused pete83 Linux - Server 12 08-05-2013 07:39 AM
vsftpd SSL problem (522 SSL connection failed) stringZ Linux - Server 8 05-05-2009 02:27 PM
inet<---eth1[LinuxBox_1]eth0<---e0[LinuxBox_2] : LinuxBox_2 hv no inet connection? Andrea_44 Linux - Networking 5 10-25-2006 08:18 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration