Re: Need Net::FTP delete help
by haukex (Archbishop) on Feb 08, 2017 at 09:52 UTC
|
Hi Todd Chester,
a lot of stuff in Net::FTP does not work correctly
As soonix told you here last week, a lot depends on the FTP server, and sometimes they simply don't support certain things. One way to approach the problem might be to compare a different FTP client to Net::FTP. If the operation does work from a different client, you could use Wireshark to trace the connection and compare what the two clients are doing differently (unless you're using encrypted connections?).
AAAAAAHHHHHHH!!!!!!!!!!!
Considering that you've apparently been doing battle with FTP for at least a week now, two thoughts: First, I know the following suggestion may be frustrating, but sometimes it's necessary to consider. Second: Perhaps you might want to take a step back. In this post, you seem to indicate that you have shell access to the server machine. Why are you using FTP? Have you considered using SSH and SFTP instead? Also, taking a step back can mean to take a couple of hours to just read all the available documentation: the server*, the protocol (perhaps even including the RFCs), and the client.
* I saw which server you're using in one of your other posts from last week. It would be best to mention this in each of your posts, since it took me a while to find this information.
Regards, -- Hauke D
| [reply] |
|
|
Hi Hauke,
The ftp server is vsftpd-3.0.3-3.fc25.x86_64 running on Fedora Core 25.
The Client is Windows 7 Professional, x64 full updated. And Cobian Backup 11
Everything is running on a local network. No Internet involved.
One of the backup sets on Cobian is writing to the FTP server. This is one of my methods of messing with the minds of Ransomware. (It is not my only one)
Even on it's better days, Cobian has a hassle and a half pruning old backup sets, be they to local drive or an FTP server. So, I write my own rotator wrappers to prune things. This program I am working on now, is to rotate the FTP backup sets from Cobian.
Cobian does not support those other fancy formats you mentioned.
As the "administrator". I have remote access to both machines. I set up the ftp server, rules and all. Makes it nice to see what is actually going on after a backup set goes off from Cobian
And, as I mentioned previously, I am able to use a Linux ftp client to delete file and directories starting with a dot.
-T
| [reply] |
|
|
| [reply] |
|
|
| [reply] |
|
|
|
|
| [reply] |
|
|
Re: Need Net::FTP delete help
by marto (Cardinal) on Feb 08, 2017 at 09:34 UTC
|
"How in the world do I work around this one?"
Did you look at the Net::FTP documentation? It shows how to return errors when things don't work, and how to enable debugging.
| [reply] |
Re: Need Net::FTP delete help
by Corion (Patriarch) on Feb 08, 2017 at 08:09 UTC
|
In what sense do you mean "can not delete"?
Do you get an error message from the module? Do you get an error message from the ftp server?
Does deleting a file with a dot at the start of the name work from the command line ftp client? What commands does the command line client send? Does it work if your program sends the same commands?
| [reply] |
|
|
Net::FTP::delete will return a true if it deletes the file
if ( $ftp->delete ( "$Target/$FileName" ) ) {
print "File <$Target/$FileName> was deleted\n";
} else {
print "File <$Target/$FileName> failed to delete\n";
}
I can delete from bash on the server. I have no idea about ftp on Windows as it doesn't support passive and my ftp sever kick it out with great disdain
The file permissions are all 0755
I could try from a Linux ftp terminal, but that would be cheating
I finally broke down and created a cronjob on the ftp server that calls a perl 5 script that changes all files and directories on the target ftp directories that start with a "." to "dot."
-T | [reply] [d/l] |
|
|
I asked:
Does deleting a file with a dot at the start of the name work from the command line ftp client?
I take this as you trying to address this:
I can delete from bash on the server.
This is not what I meant. I meant using a remote machine, using another ftp client.
If you cannot delete the file using any other FTP client via the ftp server, then the problem is not with Net::FTP but most likely with the ftp server.
If the Windows default client does not support passive mode, then maybe you can check using curl or wget, or some other approach with a client separate from Net::FTP.
| [reply] |
|
|
> Does deleting a file with a dot at the start of the name work from the command line ftp client?
yes it does from ftp-0.17-70.fc24.x86_64 Windows ftp client gets its butt kicked out as it doesn't support passive mode
>What commands does the command line client send?
delete filename
>Does it work if your program sends the same commands?
Can't test as their Internet is down. I will soon try "quot"
I sincerely appreciate all you guys help
When the customer's Internet comes back up, I have a test script I will run at it and report over to the bug I created on this at https://rt.cpan.org/Public/Bug/Display.html?id=120140 The bug contain versions etc.
| [reply] |
|
|
The command returns a zero. "ls" on the server side confirms the file/directory is still there
| [reply] |
Re: Need Net::FTP delete help
by Todd Chester (Scribe) on Feb 10, 2017 at 04:15 UTC
|
Hi All,
When the customer's Internet comes backup up (we are dead nuts on the Pineapple Express and are having 85+ MPH winds and he turned everything off, plus Charter is down city wide), I am going to try:
sub DeleteDirectly ( $ ) {
my $Target = $_[0];
print "Attempting to delete $Target\n";
if ( $ftp->quot ( "delete", "$Target" ) )
{ print "File $Target was quot deleted\n\n"; }
else
{ print "File $Target failed to quot delete\n\n"; };
}
| [reply] [d/l] |