Hello guys, I've dealt with perl for some time but I've never FTP'd before. I have a project whereby I need to FTP into a server, and look into multiple directories and find certain files and copy those files into a directory in a different server where I'm running the script from.

Every Perl script you write should include the warnings and strict pragma which will help you write better quality code and point out common mistakes that can be difficult to track down. Use strict; use warnings;

Your date calculation can be simplified with the use of the strftime function from the POSIX module. Use POSIX qw/strftime/; my $Yday = strftime("R%y%m%d", localtime(time - 86400));

Purely as matter of style and following “Perl Best Practices” it's best to keep your line lengths below 80 chars. Which in this case means to split the @myDIR assignment across multiple lines and put it in column format.

all of perls builtin functions are all lower-case and all pragams are lower-case. Perl is case-sensitive so you need to know where you can use upper and lower case characters in perl code. -------------------------------------------------

I'm sorry I'm not being forthwith with my explanations. The files I am trying to copy are CDRs or call logs for a telecommunications company. These CDRs/AMA files do not have a file extension. The content are simply in binary code, thus I do not want to transfer them in ASCII mode. The problem is that whenever I remove the $ftp->binary, the files are found and transferred successfully in the ASCII mode, which are useless to me at that point. The reason why I have the chdir "/home/AMA" ... I don't really know why I have it, but I saw it on a sample code, but basically it is the repository where I want the files copied to.

*Note: The script is ran from the backup server. It's suppose to log into our 'SWITCH' and retrieve the files that are found and are then copied to the same backup server.

The code I'm trying to achieve is one that would log into our 'SWITCH' and check the directories for yesterday's CDRs and copy them into a backup server.

If I haven't stressed it enough, I really need them to be copied/transferred in binary mode, since ASCII would corrupt the file.

I hope I'm being more direct with my purpose, and I really appreciate you taking time to help me with this problem.

Thanks.

Oh btw ... The posix code that you had given me before did not work. I had the same error I had stated before, and I had 'use'. That's why I am still using my original code. Maybe if you repost the code, I can copy and paste it and see if it works.

Oh btw ... The posix code that you had given me before did not work. I had the same error I had stated before, and I had 'use'. That's why I am still using my original code. Maybe if you repost the code, I can copy and paste it and see if it works.

Well I'm glad I've learned plenty from your help, but it sucks I can't get this script to work. I'll take your advice and look at the SFTP option. I don't know how long it will take me to write it, but I hope you're still around to guide me.

For all the rest of the forum, I hope this script helps them if they want it to work in ASCII code.