Thread net::ftp mit version 5.05 (9 answers)
Opened by DocJunioR at 2005-09-02 14:36

DocJunioR
 2005-09-02 14:54
#38464 #38464
User since
2005-08-29
53 Artikel
BenutzerIn
[default_avatar]
Unwahrscheinlich. Derzeit habe ich nichts weiter getan, als folgende Zeilen einzubauen:

use lib "Z:/perl583/lib";
use Net::FTP;

Es ist noch keine Zeile FTP-Code geschrieben worden.

Das Modul selber besteht aus einem Dialogfenster mit 2 HLists. (eine für das lokale Verzeichnis und eine für das Remoteverzeichnis)

Naja, trotzdem. Hier der Code (dann könnt ihr mir gleich noch nen paar Anmerkungen zun Stil geben - muss ja noch was lernen ;) ) :
Code: (dl )
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/usr/bin/perl -w
# ################################################
# cwidget.pm # perl 5
# ############
#
# MoniQuE - Administration
#
# cFile-Klasse
#
#
# ################################################
# don't use strict;

use lib "Z:/perl583/lib";
use warnings;
use Tk;
use Tk::DialogBox;
use Tk::HList;
use Net::FTP;

package prj::ftpdialog;

sub new
{
my $this = shift;
my $thisref = ref($this) || $this;
my $self;
$self->{'parent'} = $_[0];
$self->{"ftpuser"} = "qstest";
$self->{"ftppass"} = "qs-test";
$self->{"ftpserver"} = "monique";
$self->{"remoteroot"} = $_[1];
$self->{"localroot"} = $_[2];
$self->{"locallist"} = undef;
$self->{"remotelist"} = undef;

bless ($self, $thisref);
return $self;
}

sub Show
{
my $self = shift;

my $dialog = $self->{'parent'}->DialogBox (
-title => "FTP-Transfer",
-default_button => "Exit",
-buttons => ['Exit'],
);
# positioning frames

my $dheadl = $dialog->add ('Frame')->pack(-side=>'left');
my $dheadr = $dialog->add ('Frame')->pack(-side=>'right');
my $dheadc = $dialog->add ('Frame')->pack(-side=>'bottom');

# Create Heads
$dheadl->Label( -text => "Lokales Laufwerk",

)->pack(-side =>'top', -fill=>'y');

$dheadr->Label( -text => "Entferntes Laufwerk",

)->pack(-side =>'top', -fill=>'y');
# Create local view
my $locallist = $dheadl->Scrolled(


'HList',
-header => 1,
-columns => 3,
-width => 50,
-command => sub{localclick();},


)->pack(-side =>'bottom', -anchor => 'w');

$locallist->header('create', 0, -text => 'Dateiname');
$locallist->header('create', 1, -text => 'Datum');
$locallist->header('create', 2, -text => 'OGA');


$locallist->columnWidth (1, -char => 20);
$locallist->columnWidth (2, -char => 5);
$self->{'locallist'} = $locallist;

&reloadlocaldir($self);

# Create remote view
my $remotelist = $dheadr->Scrolled(
'HList',
-header => 1,
-columns => 3,
-width => 50,
-command => sub{remoteclick();},
)->pack(-side =>'bottom', -anchor => 'e');

$remotelist->header('create', 0, -text => 'Dateiname');
$remotelist->header('create', 1, -text => 'Datum');
$remotelist->header('create', 2, -text => 'OGA');


$remotelist->columnWidth (1, -char => 20);
$remotelist->columnWidth (2, -char => 5);
$self->{'remotelist'} = $remotelist;

&reloadremotedir($self);

# create Button List
$dialog->Show();
return;
}

# reload directory content
sub reloadlocaldir
{
my $self = $_[0];
print "opening $self->{'localroot'}\n";
opendir(DIR,$self->{'localroot'}) or die $!;
$self->{'locallist'}->delete("all");

while(my $file = readdir(DIR)){
my $path = $self->{'localroot'}.'/'.$file;
my ($date,$permissions) = (stat($path))[8,2];
my @sdate = localtime($date);
$date = sprintf ("%02i.%02i.%04i %02i:%02i:%02i", $sdate[3], $sdate[4], $sdate[5] + 1900, $sdate[2], $sdate[1], $sdate[0]);
$permissions = sprintf("%4o",$permissions & 07777);
$self->{'locallist'}->add($i);
if (-d $path)
{

$file .= "/";
}
my $l = 0;
for($file,$date,$permissions){
$self->{'locallist'}->itemCreate($i,$l,-text => $_);
$l++;
}
$i++;
}

closedir (DIR);

}

# reload directory content
sub reloadremotedir
{
my $self = $_[0];

opendir(DIR,$self->{'remoteroot'}) or die $!;

$self->{'remotelist'}->delete("all");
while(my $file = readdir(DIR)){
my $path = $self->{'remoteroot'}.'/'.$file;
my ($date,$permissions) = (stat($path))[8,2];
my @sdate = localtime($date);
$date = sprintf ("%02i.%02i.%04i %02i:%02i:%02i", $sdate[3], $sdate[4], $sdate[5] + 1900, $sdate[2], $sdate[1], $sdate[0]);
$permissions = sprintf("%4o",$permissions & 07777);
$$self->{'remotelist'}->add($i);
if (-d $path)
{

$file .= "/";
}
my $l = 0;
for($file,$date,$permissions){
$self->{'remotelist'}->itemCreate($i,$l,-text => $_);
$l++;
}
$i++;
}

closedir (DIR);

}

sub localclick
{
my $self = shift;
}

sub remoteclick
{
my $self = shift;
}

return 1;
\n\n

<!--EDIT|renee|1125659071-->

View full thread net::ftp mit version 5.05