FTP: Difference between revisions

Content added Content deleted
(Added Bash / Unix Shell Implementation)
m (syntax highlighting fixup automation)
Line 7: Line 7:
=={{header|BaCon}}==
=={{header|BaCon}}==
Using libCURL.
Using libCURL.
<lang bacon>OPTION PARSE FALSE
<syntaxhighlight lang="bacon">OPTION PARSE FALSE


PRAGMA INCLUDE <curl/curl.h>
PRAGMA INCLUDE <curl/curl.h>
Line 23: Line 23:
curl_easy_cleanup(easyhandle)
curl_easy_cleanup(easyhandle)


CLOSE FILE download</lang>
CLOSE FILE download</syntaxhighlight>


Full native implementation without dependency to external libraries.
Full native implementation without dependency to external libraries.
<lang bacon>FUNCTION interact$(command$, connection, use_pasv)
<syntaxhighlight lang="bacon">FUNCTION interact$(command$, connection, use_pasv)


LOCAL pasv$, data$, response$
LOCAL pasv$, data$, response$
Line 71: Line 71:
PRINT interact$("QUIT", ftp, 0)
PRINT interact$("QUIT", ftp, 0)


CLOSE NETWORK ftp</lang>
CLOSE NETWORK ftp</syntaxhighlight>


=={{header|Batch File}}==
=={{header|Batch File}}==
This uses the native FTP.EXE in Windows. I am not sure, but I think FTP.EXE client does not support passive mode.
This uses the native FTP.EXE in Windows. I am not sure, but I think FTP.EXE client does not support passive mode.
<lang dos>::Playing with FTP
<syntaxhighlight lang="dos">::Playing with FTP
::Batch File Implementation
::Batch File Implementation


Line 98: Line 98:
echo.get %download%
echo.get %download%
echo.disconnect
echo.disconnect
)|ftp -n</lang>
)|ftp -n</syntaxhighlight>
{{Out}}
{{Out}}
<pre>\Desktop>RCFTP
<pre>\Desktop>RCFTP
Line 130: Line 130:
=={{header|C}}==
=={{header|C}}==
Using [http://nbpfaus.net/~pfau/ftplib/ ftplib]
Using [http://nbpfaus.net/~pfau/ftplib/ ftplib]
<syntaxhighlight lang="c">
<lang c>
#include <ftplib.h>
#include <ftplib.h>


Line 148: Line 148:
return 0;
return 0;
}
}
</syntaxhighlight>
</lang>


=={{header|C++}}==
=={{header|C++}}==
Line 154: Line 154:


Using [http://nbpfaus.net/~pfau/ftplib/ ftplib], [https://github.com/saur0n/libftpxx libftp++]
Using [http://nbpfaus.net/~pfau/ftplib/ ftplib], [https://github.com/saur0n/libftpxx libftp++]
<lang cpp> /* client.cpp
<syntaxhighlight lang="cpp"> /* client.cpp
libftp++ C++ classes for ftplib C ftp library
libftp++ C++ classes for ftplib C ftp library
Line 493: Line 493:
}
}
/* END */
/* END */
</syntaxhighlight>
</lang>


{{Out}}
{{Out}}
Line 539: Line 539:
Using package [http://code.kepibu.org/cl-ftp/ cl-ftp].
Using package [http://code.kepibu.org/cl-ftp/ cl-ftp].


<lang lisp>(use-package :ftp)
<syntaxhighlight lang="lisp">(use-package :ftp)


(with-ftp-connection (conn :hostname "ftp.hq.nasa.gov"
(with-ftp-connection (conn :hostname "ftp.hq.nasa.gov"
Line 547: Line 547:
(let ((filename "Gravity in the Brain.mp3"))
(let ((filename "Gravity in the Brain.mp3"))
(retrieve-file conn filename filename :type :binary)))
(retrieve-file conn filename filename :type :binary)))
</syntaxhighlight>
</lang>
{{Out}}
{{Out}}
<pre>
<pre>
Line 565: Line 565:
=={{header|Erlang}}==
=={{header|Erlang}}==
Erlang implementation using ftp module.
Erlang implementation using ftp module.
<lang erlang>
<syntaxhighlight lang="erlang">
%%%-------------------------------------------------------------------
%%%-------------------------------------------------------------------
%%% To execute in shell, Run the following commands:-
%%% To execute in shell, Run the following commands:-
Line 608: Line 608:
io:format("Closing connection to FTP Server"),
io:format("Closing connection to FTP Server"),
ftp:close(Pid).
ftp:close(Pid).
</syntaxhighlight>
</lang>




Line 614: Line 614:
=={{header|FutureBasic}}==
=={{header|FutureBasic}}==
FB for Mac easily interfaces with the terminal command line. NOTE: The curl command line tool used in this example offers upload and sending capabilities. It supports FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS, FILE, POP3, IMAP, SMTP, RTMP and RTSP.
FB for Mac easily interfaces with the terminal command line. NOTE: The curl command line tool used in this example offers upload and sending capabilities. It supports FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS, FILE, POP3, IMAP, SMTP, RTMP and RTSP.
<lang futurebasic>
<syntaxhighlight lang="futurebasic">
include "NSLog.incl"
include "NSLog.incl"


Line 646: Line 646:


HandleEvents
HandleEvents
</syntaxhighlight>
</lang>
{{output}}
{{output}}
<pre style="font-size: 12px">
<pre style="font-size: 12px">
Line 676: Line 676:
=={{header|Go}}==
=={{header|Go}}==
Using the FTP package from [https://godoc.org/github.com/stacktic/ftp github.com/stacktic/ftp].
Using the FTP package from [https://godoc.org/github.com/stacktic/ftp github.com/stacktic/ftp].
<lang go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 737: Line 737:


fmt.Println("Wrote", n, "bytes to", file)
fmt.Println("Wrote", n, "bytes to", file)
}</lang>
}</syntaxhighlight>




Line 746: Line 746:
Dependencies are automatically loaded with the @Grab annotation.
Dependencies are automatically loaded with the @Grab annotation.
let's say the code is saved in the file ftpTest.groovy:
let's say the code is saved in the file ftpTest.groovy:
<syntaxhighlight lang="groovy">
<lang Groovy>
@Grab(group='commons-net', module='commons-net', version='2.0')
@Grab(group='commons-net', module='commons-net', version='2.0')
import org.apache.commons.net.ftp.FTPClient
import org.apache.commons.net.ftp.FTPClient
Line 761: Line 761:
}
}
println(" ...Done.");
println(" ...Done.");
</syntaxhighlight>
</lang>
By typing groovy ftpTest.groovy, you should see a README.html file on your directory.
By typing groovy ftpTest.groovy, you should see a README.html file on your directory.
<pre>
<pre>
Line 782: Line 782:
Example uses [https://hackage.haskell.org/package/ftphs <tt>ftphs</tt>] package:
Example uses [https://hackage.haskell.org/package/ftphs <tt>ftphs</tt>] package:


<lang haskell>module Main (main) where
<syntaxhighlight lang="haskell">module Main (main) where


import Control.Exception (bracket)
import Control.Exception (bracket)
Line 812: Line 812:
-- Download in binary mode
-- Download in binary mode
(fileData, _) <- getbinary h "linux-0.01.tar.gz.sign"
(fileData, _) <- getbinary h "linux-0.01.tar.gz.sign"
print fileData</lang>
print fileData</syntaxhighlight>


=={{header|J}}==
=={{header|J}}==


<lang J> require 'web/gethttp'
<syntaxhighlight lang="j"> require 'web/gethttp'
gethttp 'ftp://anonymous:example@ftp.hq.nasa.gov/pub/issoutreach/Living%20in%20Space%20Stories%20(MP3%20Files)/'
gethttp 'ftp://anonymous:example@ftp.hq.nasa.gov/pub/issoutreach/Living%20in%20Space%20Stories%20(MP3%20Files)/'
-rw-rw-r-- 1 109 space-station 2327118 May 9 2005 09sept_spacepropulsion.mp3
-rw-rw-r-- 1 109 space-station 2327118 May 9 2005 09sept_spacepropulsion.mp3
Line 830: Line 830:
-rw-rw-r-- 1 109 space-station 1134654 May 9 2005 When Space Makes you Dizzy.mp3
-rw-rw-r-- 1 109 space-station 1134654 May 9 2005 When Space Makes you Dizzy.mp3
#file=: gethttp rplc&(' ';'%20') 'ftp://anonymous:example@ftp.hq.nasa.gov/pub/issoutreach/Living in Space Stories (MP3 Files)/We have a solution.mp3'
#file=: gethttp rplc&(' ';'%20') 'ftp://anonymous:example@ftp.hq.nasa.gov/pub/issoutreach/Living in Space Stories (MP3 Files)/We have a solution.mp3'
772075</lang>
772075</syntaxhighlight>


=={{header|Java}}==
=={{header|Java}}==
requires apache.commons.net
requires apache.commons.net
<lang java>import java.io.FileOutputStream;
<syntaxhighlight lang="java">import java.io.FileOutputStream;
import java.io.IOException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStream;
Line 906: Line 906:
}
}
}
}
}</lang>
}</syntaxhighlight>


Output:
Output:
Line 954: Line 954:
{{works with|Julia|0.6}}
{{works with|Julia|0.6}}


<lang julia>using FTPClient
<syntaxhighlight lang="julia">using FTPClient


ftp = FTP(hostname = "ftp.ed.ac.uk", username = "anonymous")
ftp = FTP(hostname = "ftp.ed.ac.uk", username = "anonymous")
Line 961: Line 961:
bytes = read(download(ftp, "make.notes.tar"))
bytes = read(download(ftp, "make.notes.tar"))


close(ftp)</lang>
close(ftp)</syntaxhighlight>


=={{header|Kotlin}}==
=={{header|Kotlin}}==
Line 996: Line 996:
</pre>
</pre>
Next, you need to compile the following Kotlin program, linking against ftplib.klib.
Next, you need to compile the following Kotlin program, linking against ftplib.klib.
<lang scala>// Kotlin Native v0.6
<syntaxhighlight lang="scala">// Kotlin Native v0.6


import kotlinx.cinterop.*
import kotlinx.cinterop.*
Line 1,013: Line 1,013:
FtpQuit(vnbuf)
FtpQuit(vnbuf)
nativeHeap.free(nbuf)
nativeHeap.free(nbuf)
}</lang>
}</syntaxhighlight>
Finally, the resulting .kexe file should be executed producing something similar to the following output:
Finally, the resulting .kexe file should be executed producing something similar to the following output:
<pre>
<pre>
Line 1,034: Line 1,034:
=={{header|Lingo}}==
=={{header|Lingo}}==
{{libheader|Curl Xtra}}
{{libheader|Curl Xtra}}
<lang lingo>CURLOPT_URL = 10002
<syntaxhighlight lang="lingo">CURLOPT_URL = 10002
ch = xtra("Curl").new()
ch = xtra("Curl").new()
url = "ftp://domain.com"
url = "ftp://domain.com"
Line 1,051: Line 1,051:
ch.setOption(CURLOPT_URL, url & filename)
ch.setOption(CURLOPT_URL, url & filename)
ch.setDestinationFile(_movie.path & filename)
ch.setDestinationFile(_movie.path & filename)
res = ch.exec()</lang>
res = ch.exec()</syntaxhighlight>


=={{header|LiveCode}}==
=={{header|LiveCode}}==
<lang LiveCode>libURLSetFTPMode "passive" --default is passive anyway
<syntaxhighlight lang="livecode">libURLSetFTPMode "passive" --default is passive anyway
put url "ftp://ftp.hq.nasa.gov/" into listing
put url "ftp://ftp.hq.nasa.gov/" into listing
repeat for each line ftpln in listing
repeat for each line ftpln in listing
Line 1,092: Line 1,092:
e.g. to know the working directory, issue "pwd", we could issue "list" for above too,
e.g. to know the working directory, issue "pwd", we could issue "list" for above too,
but using an url with slash on the end with the ftp protocol causes a dir listing by default.
but using an url with slash on the end with the ftp protocol causes a dir listing by default.
put libURLftpCommand("PWD",ftp.example.org)</lang>
put libURLftpCommand("PWD",ftp.example.org)</syntaxhighlight>


=={{header|Nim}}==
=={{header|Nim}}==
Line 1,098: Line 1,098:
{{works with|Nim|1.4}}
{{works with|Nim|1.4}}


<lang nim>import asyncdispatch, asyncftpclient
<syntaxhighlight lang="nim">import asyncdispatch, asyncftpclient


const
const
Line 1,127: Line 1,127:
echo await ftp.send("QUIT") # Disconnect.
echo await ftp.send("QUIT") # Disconnect.


waitFor main()</lang>
waitFor main()</syntaxhighlight>


{{out}}
{{out}}
Line 1,149: Line 1,149:


=={{header|Perl}}==
=={{header|Perl}}==
<lang perl>use Net::FTP;
<syntaxhighlight lang="perl">use Net::FTP;


# set server and credentials
# set server and credentials
Line 1,170: Line 1,170:
$f->type('binary');
$f->type('binary');
$local = $f->get('512KB.zip');
$local = $f->get('512KB.zip');
print "Your file was stored as $local in the current directory\n";</lang>
print "Your file was stored as $local in the current directory\n";</syntaxhighlight>
{{out}}
{{out}}
<pre>Currently 20 files in the 'upload' directory
<pre>Currently 20 files in the 'upload' directory
Line 1,177: Line 1,177:
=={{header|Phix}}==
=={{header|Phix}}==
{{libheader|Phix/libcurl}}
{{libheader|Phix/libcurl}}
<!--<lang Phix>(notonline)-->
<!--<syntaxhighlight lang="phix">(notonline)-->
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- libcurl, allocate, file i/o</span>
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- libcurl, allocate, file i/o</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">libcurl</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">libcurl</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 1,202: Line 1,202:
<span style="color: #0000FF;">?{</span><span style="color: #008000;">"error"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">res</span><span style="color: #0000FF;">}</span>
<span style="color: #0000FF;">?{</span><span style="color: #008000;">"error"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">res</span><span style="color: #0000FF;">}</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{out}}
{{out}}
<pre>
<pre>
Line 1,227: Line 1,227:


=={{header|PHP}}==
=={{header|PHP}}==
<lang php>
<syntaxhighlight lang="php">
$server = "speedtest.tele2.net";
$server = "speedtest.tele2.net";
$user = "anonymous";
$user = "anonymous";
Line 1,248: Line 1,248:
} else {
} else {
echo "failed to download file";
echo "failed to download file";
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,279: Line 1,279:
=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
Passive is the default behavior of 'curl'
Passive is the default behavior of 'curl'
<lang PicoLisp>(in '(curl "-sl" "ftp://kernel.org/pub/site/")
<syntaxhighlight lang="picolisp">(in '(curl "-sl" "ftp://kernel.org/pub/site/")
(while (line)
(while (line)
(prinl @) ) )
(prinl @) ) )
(call "curl" "-s" "-o" "sha256sums.asc" "ftp://kernel.org/pub/site/sha256sums.asc")</lang>
(call "curl" "-s" "-o" "sha256sums.asc" "ftp://kernel.org/pub/site/sha256sums.asc")</syntaxhighlight>
Output:
Output:
<pre>README
<pre>README
Line 1,290: Line 1,290:
=={{header|Python}}==
=={{header|Python}}==
{{works with|Python|2.7.10}}
{{works with|Python|2.7.10}}
<syntaxhighlight lang="python">
<lang Python>
from ftplib import FTP
from ftplib import FTP
ftp = FTP('kernel.org')
ftp = FTP('kernel.org')
Line 1,299: Line 1,299:
print ftp.retrbinary('RETR README', open('README', 'wb').write)
print ftp.retrbinary('RETR README', open('README', 'wb').write)
ftp.quit()
ftp.quit()
</syntaxhighlight>
</lang>


=={{header|Racket}}==
=={{header|Racket}}==
Note: <tt>net/ftp</tt> in Racket uses passive mode exclusively.
Note: <tt>net/ftp</tt> in Racket uses passive mode exclusively.
<lang racket>
<syntaxhighlight lang="racket">
#lang racket
#lang racket
(require net/ftp)
(require net/ftp)
Line 1,319: Line 1,319:
(ftp-download-file conn "." "README")
(ftp-download-file conn "." "README")
(ftp-close-connection conn))
(ftp-close-connection conn))
</syntaxhighlight>
</lang>


=={{header|Raku}}==
=={{header|Raku}}==
Line 1,325: Line 1,325:
{{works with|rakudo|2018.04}}
{{works with|rakudo|2018.04}}


<lang perl6>use Net::FTP;
<syntaxhighlight lang="raku" line>use Net::FTP;


my $host = 'speedtest.tele2.net';
my $host = 'speedtest.tele2.net';
Line 1,341: Line 1,341:
say $_<name> for $ftp.ls;
say $_<name> for $ftp.ls;


$ftp.get( '1KB.zip', :binary );</lang>
$ftp.get( '1KB.zip', :binary );</syntaxhighlight>


{{out}}
{{out}}
Line 1,364: Line 1,364:


=={{header|REBOL}}==
=={{header|REBOL}}==
<syntaxhighlight lang="rebol">
<lang REBOL>
system/schemes/ftp/passive: on
system/schemes/ftp/passive: on
print read ftp://kernel.org/pub/linux/kernel/
print read ftp://kernel.org/pub/linux/kernel/
write/binary %README read/binary ftp://kernel.org/pub/linux/kernel/README
write/binary %README read/binary ftp://kernel.org/pub/linux/kernel/README
</syntaxhighlight>
</lang>


=={{header|Ruby}}==
=={{header|Ruby}}==
<lang ruby>require 'net/ftp'
<syntaxhighlight lang="ruby">require 'net/ftp'


Net::FTP.open('ftp.ed.ac.uk', "anonymous","aaa@gmail.com" ) do |ftp|
Net::FTP.open('ftp.ed.ac.uk', "anonymous","aaa@gmail.com" ) do |ftp|
Line 1,378: Line 1,378:
puts ftp.list
puts ftp.list
ftp.getbinaryfile("make.notes.tar")
ftp.getbinaryfile("make.notes.tar")
end</lang>
end</syntaxhighlight>
The connection is closed automatically at the end of the block.
The connection is closed automatically at the end of the block.


=={{header|Rust}}==
=={{header|Rust}}==
Using crate <code>ftp</code> version 3.0.1
Using crate <code>ftp</code> version 3.0.1
<lang Rust>use std::{error::Error, fs::File, io::copy};
<syntaxhighlight lang="rust">use std::{error::Error, fs::File, io::copy};
use ftp::FtpStream;
use ftp::FtpStream;


Line 1,397: Line 1,397:
copy(&mut stream, &mut file)?;
copy(&mut stream, &mut file)?;
Ok(())
Ok(())
}</lang>
}</syntaxhighlight>


=={{header|Scala}}==
=={{header|Scala}}==
{{libheader|commons-net}}
{{libheader|commons-net}}
<lang Scala>import java.io.{File, FileOutputStream, InputStream}
<syntaxhighlight lang="scala">import java.io.{File, FileOutputStream, InputStream}


import org.apache.commons.net.ftp.{FTPClient, FTPFile, FTPReply}
import org.apache.commons.net.ftp.{FTPClient, FTPFile, FTPReply}
Line 1,478: Line 1,478:
ftpClient.logout
ftpClient.logout
}.isFailure) println(s"Failure.")
}.isFailure) println(s"Failure.")
}</lang>
}</syntaxhighlight>
{{Out}}See it in running in your browser by [https://scastie.scala-lang.org/3Lq8ehzIQTCuAOPXWofNLw Scastie (JVM)].
{{Out}}See it in running in your browser by [https://scastie.scala-lang.org/3Lq8ehzIQTCuAOPXWofNLw Scastie (JVM)].


Line 1,485: Line 1,485:
[http://seed7.sourceforge.net/libraries/ftp.htm#openFtp(in_string) open] and handle an
[http://seed7.sourceforge.net/libraries/ftp.htm#openFtp(in_string) open] and handle an
[http://seed7.sourceforge.net/libraries/ftp.htm#ftpFileSys ftpFileSys].
[http://seed7.sourceforge.net/libraries/ftp.htm#ftpFileSys ftpFileSys].
<lang seed7>$ include "seed7_05.s7i";
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "ftp.s7i";
include "ftp.s7i";


Line 1,502: Line 1,502:
writeln(getFile(ftp, "README"));
writeln(getFile(ftp, "README"));
close(ftp);
close(ftp);
end func;</lang>
end func;</syntaxhighlight>


=={{header|Sidef}}==
=={{header|Sidef}}==
{{trans|Ruby}}
{{trans|Ruby}}
<lang ruby>require('Net::FTP');
<syntaxhighlight lang="ruby">require('Net::FTP');


var ftp = %s'Net::FTP'.new('ftp.ed.ac.uk', Passive => 1);
var ftp = %s'Net::FTP'.new('ftp.ed.ac.uk', Passive => 1);
Line 1,514: Line 1,514:
ftp.binary; # set binary mode
ftp.binary; # set binary mode
ftp.get("make.notes.tar");
ftp.get("make.notes.tar");
ftp.quit;</lang>
ftp.quit;</syntaxhighlight>


=={{header|Tcl}}==
=={{header|Tcl}}==
===Using package ftp===
===Using package ftp===
<syntaxhighlight lang="tcl">
<lang Tcl>
package require ftp
package require ftp


Line 1,528: Line 1,528:
::ftp::Type $conn binary
::ftp::Type $conn binary
::ftp::Get $conn README README
::ftp::Get $conn README README
</syntaxhighlight>
</lang>


===Using a virtual file system===
===Using a virtual file system===
An alternative approach that uses the package [http://sourceforge.net/projects/tclvfs/ TclVFS] to access ftp:// paths as a virtual file system.
An alternative approach that uses the package [http://sourceforge.net/projects/tclvfs/ TclVFS] to access ftp:// paths as a virtual file system.


<lang tcl>
<syntaxhighlight lang="tcl">
package require vfs::urltype
package require vfs::urltype
vfs::urltype::Mount ftp
vfs::urltype::Mount ftp
Line 1,546: Line 1,546:
}
}
file copy README [file join $dir README]
file copy README [file join $dir README]
</syntaxhighlight>
</lang>


The file <tt>vfsftpfix.tcl</tt> with the passive mode patch (see http://wiki.tcl.tk/12837):
The file <tt>vfsftpfix.tcl</tt> with the passive mode patch (see http://wiki.tcl.tk/12837):
<lang tcl>
<syntaxhighlight lang="tcl">
# Replace vfs::ftp::Mount to enable vfs::ftp to work in passive
# Replace vfs::ftp::Mount to enable vfs::ftp to work in passive
# mode and make that the default.
# mode and make that the default.
Line 1,600: Line 1,600:
return $fd
return $fd
}
}
</syntaxhighlight>
</lang>


=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==
Uses sftp which os available on all Linux distress by default. The commands are identical to ftp. This example uses the public free sftp server at test.rebex.net , the credentials are demo/password :
Uses sftp which os available on all Linux distress by default. The commands are identical to ftp. This example uses the public free sftp server at test.rebex.net , the credentials are demo/password :


<lang bash>
<syntaxhighlight lang="bash">
Aamrun $ sftp demo@test.rebex.net
Aamrun $ sftp demo@test.rebex.net
Password:
Password:
Line 1,623: Line 1,623:
sftp> exit
sftp> exit
Aamrun$
Aamrun$
</syntaxhighlight>
</lang>


=={{header|Wren}}==
=={{header|Wren}}==
Line 1,629: Line 1,629:
{{libheader|ftplib}}
{{libheader|ftplib}}
An embedded program so we can ask the C host to communicate with ''ftplib'' for us.
An embedded program so we can ask the C host to communicate with ''ftplib'' for us.
<lang ecmascript>/* ftp.wren */
<syntaxhighlight lang="ecmascript">/* ftp.wren */


var FTPLIB_CONNMODE = 1
var FTPLIB_CONNMODE = 1
Line 1,660: Line 1,660:
ftp.dir("", ".")
ftp.dir("", ".")
ftp.get("ftp.README", "README", FTPLIB_ASCII)
ftp.get("ftp.README", "README", FTPLIB_ASCII)
ftp.quit()</lang>
ftp.quit()</syntaxhighlight>
<br>
<br>
We now embed this in the following C program, compile and run it.
We now embed this in the following C program, compile and run it.
<lang c>#include <stdio.h>
<syntaxhighlight lang="c">#include <stdio.h>
#include <stdio_ext.h>
#include <stdio_ext.h>
#include <stdlib.h>
#include <stdlib.h>
Line 1,812: Line 1,812:
free(script);
free(script);
return 0;
return 0;
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 1,835: Line 1,835:
=={{header|zkl}}==
=={{header|zkl}}==
Using the cURL library, doing this from the REPL. Moving around in the tree isn't supported.
Using the cURL library, doing this from the REPL. Moving around in the tree isn't supported.
<lang zkl>zkl: var cURL=Import("zklCurl")
<syntaxhighlight lang="zkl">zkl: var cURL=Import("zklCurl")
zkl: var d=cURL().get("ftp.hq.nasa.gov/pub/issoutreach/Living in Space Stories (MP3 Files)/")
zkl: var d=cURL().get("ftp.hq.nasa.gov/pub/issoutreach/Living in Space Stories (MP3 Files)/")
L(Data(2,567),1630,23) // downloaded listing, 1630 bytes of header, 23 bytes of trailer
L(Data(2,567),1630,23) // downloaded listing, 1630 bytes of header, 23 bytes of trailer
Line 1,846: Line 1,846:
L(Data(1,136,358),1681,23)
L(Data(1,136,358),1681,23)
zkl: File("foo.mp3","w").write(d[0][1681,-23])
zkl: File("foo.mp3","w").write(d[0][1681,-23])
1134654 // note that this matches size in listing</lang>
1134654 // note that this matches size in listing</syntaxhighlight>
The resulting file foo.mp3 has a nice six minute description of what can happen when returning from space.
The resulting file foo.mp3 has a nice six minute description of what can happen when returning from space.