in reply to Re: Encrypt File while sending
in thread Encrypt File while sending

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

Replies are listed 'Best First'.
Re^3: Encrypt File while sending
by Utilitarian (Vicar) on Aug 20, 2009 at 22:31 UTC
    • Print to a file within the script rather than in the shell, this will allow you to automate the entire process.
    • Read the documentation of Crypt::Simple, it's fairly straightforward.
    • Substitute Net::SFTP for Net::FTP in my previous advice.
    • Seriously, you can search for things in CPAN, it's easy to do and speeds up development no end ;)