1

I wrote a Matlab GUI that's used to automate the transfer of data to and from an ftp server, which is done using cURL, e.g.

str = sprintf(' "%s" -O "ftp://%s:%s@%s" -Q "CWD %s%s/" ', ...
    handles.curl, username, password, ...
    strcat(ftpname, d{1}), '/users/', username);

% Try to transfer file until successful (s=0)
s = 1;
while s ~= 0
    s = dos(str);
end

Typically this GUI will be ran on a slow network, so transferring a 50 MB file could take up to 30 minutes or longer.

What I'd like to know is that if a "Stop" button is pressed on the GUI while it's in the middle of a data transfer, is there a way in cURL to cancel that transfer, or do I need to let it complete?

H.Muster
  • 9,297
  • 1
  • 35
  • 46
Josiah
  • 654
  • 2
  • 13
  • 25

1 Answers1

0

You could setup a timer object with a callback to check if the user hit the cancel button and then try to kill the process via a different dos command. The only thing I don't like is the whole external process cURL, it may be difficult to know you for sure got the right process. Is there a reason you didn't try any of the Matlab transfer commands?

macduff
  • 4,655
  • 18
  • 29
  • I'll give it a shot and try sending a different dos command to see if that interrupts the transfer. I originally tried using the Matlab ftp commands, but I believe I was having trouble connecting. I'm not sure if it was security issues, passive ftp issues, or what, but I had no problems when I made the switch to cURL. – Josiah Sep 27 '12 at 23:24
  • 1
    You may also try to use Java for doing this. See [this answer](http://stackoverflow.com/questions/295178/what-java-ftp-client-library-should-i-use) for good Java FTP libraries. Use a library that allows you to transfer data asynchronically. – Florian Brucker Sep 28 '12 at 05:36
  • Just to update, I tried sending another curl command during the data transfer, and although the command goes through just fine, the transfer simply resumes and continues downloading. – Josiah Sep 28 '12 at 21:32