Hi, I have the code with me. I don't know to move forward with encryption part of it and the security folks will not allow plain ftp, it has to be "sftp". To step down further, i'm looking for steps where it does the encryption and sftp. Here is the code, which will do a ldap search and convert the output to a csv format :
#!/usr/bin/perl use Net::LDAP; @fields = # fields to expo +rt ( # Label Field Name Index ['UID','uid',0], ['mail','mail',0], ['OtherPhone','OtherPhone',0], ['mobile','mobile',0], ['givenName','givenName',0], ['Initials','initials',0], ['sn','sn',0], ['c','c',0], ); $ldap = Net::LDAP->new('hostname:port') or die "$@"; # open conne +ction $mesg = $ldap->bind( # login "cn=Directory Manager", password => "$$$$$$$$$$$"); $mesg = $ldap->search( # search base => "dc=xyz,dc=com", filter => "(&(objectClass=*)(!(c=US))(uid=*))" ); $DATETIME=`date`; sub get # get field valu +e { return $_[0]->exists($_[1]) ? $_[0]->get($_[1])->[$_[2] ? $_[2] : 0] : ''; } print "$DATETIME"; # first line with file created date/ +time print '"'.(join '","', "Report", # header map {$_->[0]} @fields)."\"\n"; foreach $entry ($mesg->all_entries) # for each entry { @dn = map {s/[a-z]+=//gi; $_ = ucfirst} # organization reverse split /,/, $entry->dn; shift @dn; shift @dn; shift @dn; pop @dn; print '"'.(join '","', "@dn", # row map {get $entry, $_->[1], $_->[2]} @fields)."\"\n"; } $mesg = $ldap->unbind; # close connecti +on
I run the command like this : perl report.pl > report.csv Thanks, Pamela

In reply to Re^2: Encrypt File while sending by Anonymous Monk
in thread Encrypt File while sending by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.