4

Does anybody know if there is any way to download files from ftp server directly from Q (kdb) ? I know that it's possible to use http but didn't see any examples of using ftp. Seems only way is to write wrapper around something like curl etc, but may be it is already done ? Any thoughts ?

chrisaycock
  • 36,470
  • 14
  • 88
  • 125
mde
  • 334
  • 4
  • 9

3 Answers3

4

Why not either:

  • Write a script to fetch the file then start the q processing.
  • Use a system command to call any linux/dos commands you want, then use the kdb key command to check that the files exist as expected
Ryan Hamilton
  • 2,601
  • 16
  • 17
  • Yep Ryan, that would be a straightforward solution but not too beautiful ;) especially if I need to create separate scripts (use different additional commands) for Win and Linux platforms. So I just was curious if there is something ready for remote access to use it in KDB. Anyway seems it would be interesting challenge to implement connection to lubcurl for example. – mde Apr 30 '14 at 14:20
  • i would say just using the `system` command and something like `curl` is beautiful enough... – JPC Apr 30 '14 at 21:08
3

use a system call to curl without a file destination -- its default destination is stdout, so the file contents will be returned to q as the return value of system

data:system"curl ftp://wherever/whatever"

Aaron Davies
  • 1,190
  • 1
  • 11
  • 17
  • Yes, seems that's better (simplest) than writing wrapper around the ftp library. – mde May 01 '14 at 21:12
0

For Linux, you can simply run any curl command or system command using q. I used following for example:

system "curl --proxy my_proxy_details ftp://ftp.microsoft.com/developr/visual_c/README.TXT -o README.txt"

-> -o option is to give name for the downloaded file.

Similarly you can run other curl commands or other system commands to get ftp files in Q.

This site has good curl examples: http://www.cyberciti.biz/faq/curl-download-file-example-under-linux-unix/

Rahul
  • 3,914
  • 1
  • 14
  • 25