I am using gpg ( opensource encryption/decryption tool) to send files via
ftp to a remote site.
In my WIN32 Perl program I am trying to figure how I would do this
equivalent in Unix...

#> cat gpgpass |gpg - - "all the options" newfile encryptedfile
The gpgpass is the password that will enable decryption to occur and it has
to be piped into the gpg binary as above.

Here is my program

use strict;
use warnings;
use diagnostics;
use Net::FTP;
require 5.8.0;
$ENV{"PATH"} = qq(C:\\Perl\\bin:C:\\Documents and
Settings\\mh-hl7:C:\\Program Files\\GNU\\GnuPG\\);

my $p = qq(--passphrase-fd 0);
my $de = qq(--decrypt);
my $outp = qq(--output);
my $ascfile = qq(MHFM.txt.asc);
my $gpgpass = q{};
my $MHfile0 = qq(C:\\temp\\derek);
#my $MHfile1 = qq(C:\\Documents and Settings\\mh-hl7\\MHFM.txt.asc);
my $MHfile1 = qq(C:\\Program Files\\DzSoft\\Perl
my $pass = qq(C:\\temp\\pass.txt);

sub ftpme {
my $remotehost = "";
my $remotedir = "cloverleaf";
my $localdir = "C:\\Documents and Settings\\mh-hl7";
my $user = "....";
my $pass = ".....";
my $data = "$ascfile";
my $ftplog = "C:\\temp\\ftpxfer_to_OH.log";

open (FTPLOG, ">$ftplog") or warn "was unable to open FTPLOG $!";
my $ftp = Net::FTP->new($remotehost, Debug => 10)
or do {print FTPLOG "Cannot connect to $remotehost $!";};
$ftp->login($user,$pass) or do {print FTPLOG "Login failed $!";};
$ftp->get($ascfile) or do {print FTPLOG "Get data failed $!";};

unlink $MHfile0 or warn "was unable to unlink old file $!";


rename("$MHfile1","$MHfile0") or die "was unable to cp file to $MHfile0
if ( -s $MHfile0 ) {
open (PASS, "+<$pass") or warn "was unable to open FH $!";
for (;<PASS>;) {
$gpgpass = $_;

print $gpgpass | system ("C:\\Program Files\GNU\GnuPG\gpg $p $de $outp
$MHfile0 $ascfile");

# I know the above will not work but this is what it should conceptually
look like.
#else {
# print "file $ascfile not present","\n";
# system ("C:\\WINDOWS\\notepad.exe C:\\temp\\pass.txt");

close (PASS) or warn "was unable to close FH $!";

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
postedDec 29, '05 at 7:48p
activeDec 29, '05 at 7:48p

1 user in discussion

Dbsmith: 1 post



site design / logo © 2021 Grokbase