Hi,
is there any simple way in PowerSwitch to delete specific file from the ftp server?
using delete after download in FTP RECEIVE task doesn't solve the problem. When uploading fails on 99% because of the failure of an internet connection, it deletes partial file and customer has to upload his 2GB again and loves me. Leaving files on ftp is problem too. Because after restarting workflow it downloads all the files again.
thanks
Peter
deleting specific file from ftp server in powerswitch
-
- Newbie
- Posts: 4
- Joined: Tue Aug 09, 2011 2:07 pm
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
deleting specific file from ftp server in powerswitch
I have a couple of questions.
How do you determine which file needs to be deleted?
Does your FTP server support resuming an aborted upload?
Dwight Kelly
Apago, Inc.
dkelly@apago.com
How do you determine which file needs to be deleted?
Does your FTP server support resuming an aborted upload?
Dwight Kelly
Apago, Inc.
dkelly@apago.com
-
- Newbie
- Posts: 4
- Joined: Tue Aug 09, 2011 2:07 pm
deleting specific file from ftp server in powerswitch
dkelly wrote: I have a couple of questions.
How do you determine which file needs to be deleted?
Does your FTP server support resuming an aborted upload?
Dwight Kelly
Apago, Inc.
dkelly@apago.com
1.) I'm going to process file through some preflight to find out if it's ok. And safe the file name somewhere on the road.
2.) Yes, my FTP server supports resuming an aborted upload.
:-)
Barcode.cz
How do you determine which file needs to be deleted?
Does your FTP server support resuming an aborted upload?
Dwight Kelly
Apago, Inc.
dkelly@apago.com
1.) I'm going to process file through some preflight to find out if it's ok. And safe the file name somewhere on the road.
2.) Yes, my FTP server supports resuming an aborted upload.
:-)
Barcode.cz
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
deleting specific file from ftp server in powerswitch
One problem is a truncated PDF will fail before it gets to Pitstop Server with the error:
Error while processing file: -1, Not processed yet (getStats)
Error while processing file: -1, Not processed yet (getStats)
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
deleting specific file from ftp server in powerswitch
I was able to create a flow that deleted a "failed" job. It uses a Perl script I wrote to delete the file from the FTP server. It's not perfect. You need to reenter the server, user, password and subfolder path. It would be better if the script could read those values from job hierarchy embedded by FTP receive element.
Here's the script for FTPDelete
// FTPdel - delete file from FTP server
//
// Developed by Dwight Kelly <dkelly@apago.com>
// Copyright 2011 - Apago, Inc. -- All rights reserved
//
const cLogDebug = -1;
const cLogError = 3;
function jobArrived( s : Switch, job : Job )
{
var theServer = s.getPropertyValue("server", job);
if (theServer.length == 0) {
job.fail("FTPdel: No Server specified!");
return;
}
var thePath = s.getPropertyValue("path", job);
if (thePath.length == 0) {
job.fail("FTPdel: No path specified!");
return;
}
var String args = new Array();
var appPath = s.getSpecialFolderPath("PluginResources") + "/" + "ftpdel.pl"
args[0] = appPath;
args[1] = theServer;
args[2] = thePath;
args[3] = job.getName();
var myProc = new Process(args);
myProc.start();
myProc.waitForFinished(60);
if (myProc.exitStatus != 0) {
job.log(cLogError, "FTPdel: delete failed");
}
// delete job from flow
job.sendToNull( job.getPath() );
}
Dwight Kelly
Apago, Inc.
dkelly@apago.com
Here's the script for FTPDelete
// FTPdel - delete file from FTP server
//
// Developed by Dwight Kelly <dkelly@apago.com>
// Copyright 2011 - Apago, Inc. -- All rights reserved
//
const cLogDebug = -1;
const cLogError = 3;
function jobArrived( s : Switch, job : Job )
{
var theServer = s.getPropertyValue("server", job);
if (theServer.length == 0) {
job.fail("FTPdel: No Server specified!");
return;
}
var thePath = s.getPropertyValue("path", job);
if (thePath.length == 0) {
job.fail("FTPdel: No path specified!");
return;
}
var String args = new Array();
var appPath = s.getSpecialFolderPath("PluginResources") + "/" + "ftpdel.pl"
args[0] = appPath;
args[1] = theServer;
args[2] = thePath;
args[3] = job.getName();
var myProc = new Process(args);
myProc.start();
myProc.waitForFinished(60);
if (myProc.exitStatus != 0) {
job.log(cLogError, "FTPdel: delete failed");
}
// delete job from flow
job.sendToNull( job.getPath() );
}
Dwight Kelly
Apago, Inc.
dkelly@apago.com
-
- Newbie
- Posts: 4
- Joined: Tue Aug 09, 2011 2:07 pm
deleting specific file from ftp server in powerswitch
thanks Dwight... helped a lot
it works just fine...
Barcode.cz
it works just fine...
Barcode.cz
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
deleting specific file from ftp server in powerswitch
Here's the Perl script I called.
#!/usr/bin/perl
#
# FTPDel.pl
# Developed by Dwight Kelly <dkelly@apago.com>
#
use Net::FTP;
die "usage: ftpdel.pl SERVER DIRECTORY FILEn" if ($#ARGV+1 != 3);
my $host=$ARGV[0];
my $directory=$ARGV[1];
my $file=$ARGV[2];
my $newerr=0;
$ftp=Net::FTP->new($host,Timeout=>240) or $newerr=1;
die "Can't connect to server $host: $!n" if $newerr;
$ftp->login("USERNAME","PASSWORD") or $newerr=1;
die "Can't log into server $host: $!n" if $newerr;
$ftp->cwd($directory) or $newerr=1;
if ($newerr) {
$ftp->quit;
die "Can't change to directory $directory: $!n";
}
$ftp->delete($file) or $newerr=1;
print "Couldn't delete file $file: $!n" if $newerr;
$ftp->quit;
exit $newerr;
Dwight Kelly
Apago, Inc.
dkelly@apago.com
#!/usr/bin/perl
#
# FTPDel.pl
# Developed by Dwight Kelly <dkelly@apago.com>
#
use Net::FTP;
die "usage: ftpdel.pl SERVER DIRECTORY FILEn" if ($#ARGV+1 != 3);
my $host=$ARGV[0];
my $directory=$ARGV[1];
my $file=$ARGV[2];
my $newerr=0;
$ftp=Net::FTP->new($host,Timeout=>240) or $newerr=1;
die "Can't connect to server $host: $!n" if $newerr;
$ftp->login("USERNAME","PASSWORD") or $newerr=1;
die "Can't log into server $host: $!n" if $newerr;
$ftp->cwd($directory) or $newerr=1;
if ($newerr) {
$ftp->quit;
die "Can't change to directory $directory: $!n";
}
$ftp->delete($file) or $newerr=1;
print "Couldn't delete file $file: $!n" if $newerr;
$ftp->quit;
exit $newerr;
Dwight Kelly
Apago, Inc.
dkelly@apago.com