File: demo.net.phtml

package info (click to toggle)
eperl 2.2.14-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,164 kB
  • ctags: 348
  • sloc: ansic: 4,680; sh: 1,425; perl: 551; makefile: 378
file content (53 lines) | stat: -rw-r--r-- 1,106 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!-- 
##
##  demo.net -- ePerl demonstration webpage
##  Copyright (c) 1996,1997 Ralf S. Engelschall, All Rights Reserved. 
##
-->
<html>
<head>
<title>demo.net</title>
</head>
<body>
<blockquote>
<blockquote>
<h1>demo.net</h1>
<h2>Low-level Network programming with Net::FTP</h1>
<p>

This demonstrates how one can use the Net::FTP package (from <tt>libnet</tt>)
from within ePerl to retrieve a file via FTP. As an example the ePerl
distribution README file is fetched from
<tt>ftp://ftp.engelschall.com/sw/</tt> while the current filename (ePerl
version!) is determined on-the-fly.

<p>
And here comes the file:

<pre>
<?
use Net::FTP;
my $tmpfile = "/tmp/demo.net.tmp.$$";

#   retrieve the file a temporary file
my $ftp = Net::FTP->new("ftp.engelschall.com");
$ftp->login("ftp", "demo.ftp\@");
$ftp->cwd("/sw");
my ($f) = grep(/^eperl-.*\.readme$/, $ftp->ls("eperl-*.readme"));
$ftp->get($f, $tmpfile);
$ftp->quit;

#   read the temporary file into current page
open(FP, "<$tmpfile");
while (<FP>) {
    print $_;
}
close(FP);
unlink($tmpfile);
!>
</pre>

</blockquote>
</blockquote>
</body>
</html>