Schrift
[thread]6921[/thread]

Welche Funktion in welchem Modul?



<< >> 8 Einträge, 1 Seite
J-jayz-Z
 2005-04-22 10:43
#54124 #54124
User since
2005-04-13
625 Artikel
BenutzerIn
[Homepage] [default_avatar]
Wie kann ich den herausfinden, zu welchem Modul beispielsweise die funktion gethostbyaddr gehört?
Ich habe mir ein script geschrieben, welches unter 5.6 ging und das Modul Socket verwendete. Unter 5.8 geht es nicht mehr und das Modul Socket scheint es nicht mehr zu geben...Zumindest nicht für 5.8:-(
perl -Mstrict -Mwarnings -e 'package blub; sub new { bless {} } sub bar {my $self=shift; $self->{bla}="5065726c2d436f6d6d756e697479"; return $self->{bla};} my $foo=blub->new();print "Hallo ";print pack("H*",$foo->bar()); print "\n"'

http://perl-tutor.de
sri
 2005-04-22 12:04
#54125 #54125
User since
2004-01-29
828 Artikel
BenutzerIn
[Homepage] [default_avatar]
[quote=J-jayz-Z,22.04.2005, 08:43]Wie kann ich den herausfinden, zu welchem Modul beispielsweise die funktion gethostbyaddr gehört?
Ich habe mir ein script geschrieben, welches unter 5.6 ging und das Modul Socket verwendete. Unter 5.8 geht es nicht mehr und das Modul Socket scheint es nicht mehr zu geben...Zumindest nicht für 5.8:-([/quote]
Doch, gibts noch.
J-jayz-Z
 2005-04-22 12:07
#54126 #54126
User since
2005-04-13
625 Artikel
BenutzerIn
[Homepage] [default_avatar]
Okay, danke. Ich habe nur das Modul Socket6 gefunden. Wusste ja aber nicht, ob die Funktion darin ist. Ich werde mal suchen.
thx!
perl -Mstrict -Mwarnings -e 'package blub; sub new { bless {} } sub bar {my $self=shift; $self->{bla}="5065726c2d436f6d6d756e697479"; return $self->{bla};} my $foo=blub->new();print "Hallo ";print pack("H*",$foo->bar()); print "\n"'

http://perl-tutor.de
Strat
 2005-04-22 15:49
#54127 #54127
User since
2003-08-04
5246 Artikel
ModeratorIn
[Homepage] [default_avatar]
Socket.pm ist auch bei perl5.8 dabei, z.B.
Code: (dl )
1
2
C:>perl -e "use Socket; print $]"
5.008003

Falls nicht, hat offenbar dein Perl einen Hau abbekommen...
perl -le "s::*erlco'unaty.'.dk':e,y;*kn:ai;penmic;;print"
http://www.fabiani.net/
J-jayz-Z
 2005-04-22 22:51
#54128 #54128
User since
2005-04-13
625 Artikel
BenutzerIn
[Homepage] [default_avatar]
Stimmt, ist bei mir genauso...
Kann mir jemand helfen, und sagen, was an dem script falsch ist?
Seid meiner letzten Nutzung habe ich nicht verändert, nur auf 5.8 gewechselt. Aber das script geht jetzt nicht mehr. Fehlermeldung bekomm ich auch keine...

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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#!/usr/bin/perl
###############
#
# Autor: Ingo Walz
# Kontakt: [EMAIL=ingo@j-jayz-z.de]ingo@j-jayz-z.de[/EMAIL]
# Website: http://j-jayz-z.de
#
#Description:
#
#Dieses Script ist in der Lage, mit einer grafischen
#Oberfläche Hosts zu pingen und ihre Domain/Hostnamen in IP&´s
#aufzulösen und umgekehrt. Ich habe es bisher nur unter Windows
#getestet. Es ist allerdings Plattformunaghängig programmiert.
#Sollte also auch auf Linux laufen.
#
#
#
#Dieses script kann frei genutzt und verbreitet werden.
################
use warnings;
use strict;
#Module einbinden
use Tk;
use Net::Ping;
use Socket;

#Offene Konsole in Windows vermeiden
BEGIN {
if ($^O eq 'MSWin32')
{
require Win32::Console;
Win32::Console::Free();
}
}

#Ping Objekt erzeugen
my $p=Net::Ping->new('icmp');

#Hauptfenster erzeugen
my $main = MainWindow->new(-background => 'green');
#$main->overrideredirect(1);

#Frame erzeugen für Radiobuttons
my $main1 = $main->Frame(-width=> '25', -height=>'15')->pack();

#Haupttext
my $text = $main->Label( -text => "Bitte IP oder Hostnamen eingeben!",

-background => 'green')->pack();

#Eingabefeld erzeugen
my $input = $main->Entry(-background => 'grey', -foreground => 'red')->pack();

#Radio Variable erzeugen
my $radio_select = "0";

#Radiobuttons erzeugen
my $radio1 = $main1->Radiobutton(-text => "Ping", -background => 'green', -selectcolor => 'red', -value => '1', activebackground => 'red', -variable => \$radio_select)->pack(-side => 'left');

my $radio2 = $main1->Radiobutton(-text => "IP/Host", -background => 'green', -selectcolor => 'red', -value => '2', -activebackground => 'red', -variable => \$radio_select)->pack(-side => 'left');

my $radio3 = $main1->Radiobutton(-text => "Host/IP", -background => 'green', -selectcolor => 'red', -value => '3', -activebackground => 'red', -variable => \$radio_select)->pack(-side => 'left');


#Button erzeugen
my $button_ok = $main->Button( -text => 'Send!',

-relief => 'groove',

-activebackground => 'yellow',

-background => 'green',

-command => \&look,
)->pack(-side => 'left');

my $button_exit => $main->Button(-text => 'Exit',

-relief => 'groove',

-activebackground => 'yellow',

-background => 'green',

-command => sub { exit 0; }

)->pack(-side => 'right');

my $button_clear => $main->Button(-text => 'Clear',

-relief => 'groove',

-activebackground => 'yellow',

-background => 'green',

-command => sub {$input->delete(0, 'end')}

)->pack(-side => 'right');



#TK Programm ausführen
MainLoop();


#Subroutine look erzeugen
sub look {
if (!$radio_select)
{
#Popup für keine gewählte Funktion
my $popup = $main->Toplevel(-background => 'green');
$popup->Label(-text => "Bitte Funktion wählen!",
-background => 'green')->pack();
$popup->Button(-text => 'close',
-background => 'green',
-command => sub { $popup->destroy() } )->pack();
}

#Ping Funktion erzeugen
if ($radio_select == 1)
{
my $ping_host = $input->get();
my $error;
my $ping_okay;


if ($ping_host !~ /\d\d?\d?\.\d\d?\d?\.\d\d?\d?/ && $ping_host !~ /[A-Za-z0-9\.]+/ )
{
$error = "Die IP muss aus Zahlen bestehen!\n Der Hostname muss aus Zahlen oder Buchstaben bestehen!\n";
}
else
{

my $host = "$ping_host";

if ($p->ping($host))
{
$ping_okay = "\n$host ist erreichbar!\n";
$error="0";
}
else
{
$ping_okay = "\n$host ist nicht erreichbar!\n";
$error="0";
}
}
my $popup = $main->Toplevel(-background => 'green');
if ($error)
{
$popup->Label(-text => "$error",
-background => 'green')->pack();
}
else
{
$popup->Label(-text => "$ping_okay",
-background => 'green')->pack();
}
$popup->Button(-text => 'close',
-background => 'green',
-command => sub { $popup->destroy() } )->pack();
}

#IP/Host Funktion erzeugen
if ($radio_select == 2)
{

my $ping_host = $input->get();

my $host = $ping_host;

if ($host)
{
my $name = gethostbyaddr(inet_aton($host), AF_INET);
if ($name)
{
my $popup = $main->Toplevel(-background => 'green');
$popup->Label(-text => "$name",
-background => 'green')->pack();

$popup->Button(-text => 'close',
-background => 'green',
-command => sub { $popup->destroy() } )->pack();
}
else
{
my $error = "Konnte $host nicht auflösen!";
my $popup = $main->Toplevel(-background => 'green');
$popup->Label(-text => "$error",
-background => 'green')->pack();


$popup->Button(-text => 'close',
-background => 'green',
-command => sub { $popup->destroy() } )->pack();

$radio_select = "0";
}
}
else
{
my $popup = $main->Toplevel(-background => 'green');
$popup->Label(-text => "Bitte IP eingeben!",
-background => 'green')->pack();
$popup->Button(-text => 'close',
-background => 'green',
-command => sub { $popup->destroy() } )->pack();
}
}

#Host/IP Funktion erzeugen
if ($radio_select == 3)
{
my $ping_host = $input->get();

my $host = $ping_host;


if ($host)
{
my $name = inet_ntoa(inet_aton($host));
if ($name)
{
my $popup = $main->Toplevel(-background => 'green');
$popup->Label(-text => "$name",
-background => 'green')->pack();

$popup->Button(-text => 'close',
-background => 'green',
-command => sub { $popup->destroy() } )->pack();
}
else
{
my $error = "Konnte $host nicht auflösen!";
my $popup = $main->Toplevel(-background => 'green');
$popup->Label(-text => "$error",
-background => 'green')->pack();


$popup->Button(-text => 'close',
-background => 'green',
-command => sub { $popup->destroy() } )->pack();

$radio_select = "0";
}
}
else
{
my $popup = $main->Toplevel(-background => 'green');
$popup->Label(-text => "Bitte Domain oder Hostnamen eingeben!",
-background => 'green')->pack();
$popup->Button(-text => 'close',
-background => 'green',
-command => sub { $popup->destroy() } )->pack();
}
}
}


Danke schon mal für eure Hilfe!
perl -Mstrict -Mwarnings -e 'package blub; sub new { bless {} } sub bar {my $self=shift; $self->{bla}="5065726c2d436f6d6d756e697479"; return $self->{bla};} my $foo=blub->new();print "Hallo ";print pack("H*",$foo->bar()); print "\n"'

http://perl-tutor.de
J-jayz-Z
 2005-04-23 01:36
#54129 #54129
User since
2005-04-13
625 Artikel
BenutzerIn
[Homepage] [default_avatar]
Was soll das? Ich hab jetzt kurzzeitig wieder Perl 5.6 drauf gemacht und mein script geht wieder...
Wieso den das???
perl -Mstrict -Mwarnings -e 'package blub; sub new { bless {} } sub bar {my $self=shift; $self->{bla}="5065726c2d436f6d6d756e697479"; return $self->{bla};} my $foo=blub->new();print "Hallo ";print pack("H*",$foo->bar()); print "\n"'

http://perl-tutor.de
esskar
 2005-04-23 03:25
#54130 #54130
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
es kann keine fehlermedlung kommen, da du deinem programm die konsole unterm hintern wegziehst!
ich bekomm unter
Code: (dl )
icmp socket error -  at D:\Eigene Dateien\Entwicklung\perl\j-jayz-z-1.pl line 37


This is perl, v5.8.6 built for MSWin32-x86-multi-thread
J-jayz-Z
 2005-04-23 13:44
#54131 #54131
User since
2005-04-13
625 Artikel
BenutzerIn
[Homepage] [default_avatar]
Das hat was, so hab ich das noch gar nicht gesehen...
Wieso geht das Teil unter 5.6 aber ohne Probleme?
Das gemeinte Code ist ja dieser hier
Code: (dl )
my $p=Net::Ping->new('icmp');

und mal eine Post aus der CPAN Doku:
Code: (dl )
$p = Net::Ping->new("icmp");

Wieso beschwert er sich dann? ? ?
Das einzige ist, das Net::Ping mit ICMP die setuid des Systemadministrators haben muss, damit es läuft. Da du es ja unter WIndows ausführst, dürfte das auch der Fall sein. Wenn ich es unter Linux ausführe (als root) funktioniert das Teil auch. Und eben mit 5.6 ebenfalls. Immer der selbe Code...
perl -Mstrict -Mwarnings -e 'package blub; sub new { bless {} } sub bar {my $self=shift; $self->{bla}="5065726c2d436f6d6d756e697479"; return $self->{bla};} my $foo=blub->new();print "Hallo ";print pack("H*",$foo->bar()); print "\n"'

http://perl-tutor.de
<< >> 8 Einträge, 1 Seite



View all threads created 2005-04-22 10:43.