0

In SQL I'm using xp_cmdShell to run FTP commands. I have no problem getting the list of files or copying files to the local server, but I want to compare copied file size to the original to make sure the get has been successful.

Any ideas on how to compare file sizes?

1 Answer 1

1

From a command prompt you can use the DOS File Compare command (fc). In your case you probably want to do a binary compare (there is no file size compare). I binary compare should work in your case.

Most DOS commands will return some code that let s you know the status.

http://www.computerhope.com/fchlp.htm

EDIT Sorry, I read your question and realized you want to compare it against a file on the ftp server. I think this is a moot point since if ftp reports a successful file transfer there is no reason to compare (unless your source of comparison for not the ftp site). Does that make sense?

What you could do it use the FTP command ls command.

ftp> ls <filename>

where ftp> is the ftp prompt and not part of the command. This command gives you the file size in bytes. Then you need to use the dos command for the local file. Here is a StackOverflow question (and answer) about that. Windows command for file size only?

2
  • +1 for the link Windows Command file Size only ,but the ls doesn't work for me as I need just the size , and the reason that I have to compare is that I'm not sure if the system has finished writing the file when I'm getting the file
    – Asha
    Commented Feb 6, 2011 at 22:19
  • The ftp protocol does let you know if the job is complete. Are you not able to get that info? I've not used xp_cmdShell so I don't know specifics about it. Are you able to run other executables?
    – Shiv Kumar
    Commented Feb 7, 2011 at 10:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.