You can't just comment out code all willy nilly. There is a problem, it told you what the problem is, you need to correct it before moving on. Now I can't guess as to what the problem is because you have not shown all the code, but it sounds like mdtm is on an operating system that does not work correctly or you are not passing it file names the process has permission to query. You will need to show more/all of your code - preferrably in readmore tags. You have me worried when you say $connect is the same as $ftp. Unless you have two concurrent FTP processes going at the exact same time in the same directory you can not interchange them like you did.