my $redirectURL = 'http://'. $destination_server . '/cgi-bin/pubtools/ebom.' . $extension . '?XML=' . $randomName; ## copy our XML to the correct location/filename $logger->info("Report requested, FTP $localfile to $destination_server"); my $ftp = Net::SFTP->new($destination_server, Debug=>0); $ftp->login($login, $pass) or $logger->error("Could not connect to Pubs Server"); $ftp->cwd($destination_path) or $logger->error("Could not change directories on Pubs Server"); $ftp->put($localfile, $randomName) or $logger->error("Could not transfer file to Pubs Server"); $ftp->site('chmod','0666',$randomName) or $logger->error("Could not chmod remote file"); $ftp->quit; ## Now we redirect them to the generated PDF $logger->info("Redirecting to $redirectURL"); print $cgi->redirect(-target => 'ResultWindow', -expires => 'now', -uri=>$redirectURL);