Précédent   Forum du club des développeurs et IT Pro > Autres langages > Perl > Web
Web Toutes vos questions sur la construction de pages web en Perl (CGI, Ajax, mod_perl, sessions, ...) Avant de poster, veuillez consulter les FAQs perl, les cours Perl et les sources Perl.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 12/11/2012, 15h18   #1
inserm
Invité de passage
 
Inscription : septembre 2012
Messages : 10
Détails du profil
Informations forums :
Inscription : septembre 2012
Messages : 10
Points : 1
Points : 1
Par défaut Script envoyer un message au compte hotmail

Bonjour,

J'ai trouvé un script qui envoie un email au compte hotmail mais en testant il m'affichais l'erreur :
Code :
bash: ./msnp_status.pl : /usr/bin/perl^M : mauvais interpréteur: Aucun fichier ou dossier de ce type
voilà le code
Code :
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
#!/usr/bin/perl
#
## msnp_status.pl release 8
## Copyright (c) 2002-2005 TAKEDA Hiroyuki
#
## msnp_status.pl release 9
## Adapted for Nagios
## by Victor Detoni (victordetoni at gmail.com)
 
use Digest::MD5 qw(md5 md5_hex md5_base64);
use FileHandle;
use Socket;
use Net::SSLeay qw(get_https post_https sslcat make_headers make_form);
 
use Jcode;
#use CGI;
#$q = new CGI; 
#$message = $q->param('message');
 
# Recebe os parametros
my $message = shift;
my $send_id = shift || &usage(%ERRORS);
 
#enable for debugging
#open(LOG,">>/tmp/logmsnp.log");
#print LOG "$message $send_id";
#close (LOG);
 
$login_id = 'usermonitor@hotmail.com';
$passwd = '*******'; 
 
$Debug = 0;
$timeout = 2;
 
$ds = 'messenger.hotmail.com';
$port = '1863';
 
$| = 1;
$TrID = 0;
 
$socket = msnp_connect( $ds, $port );
 
snd_msg( $socket, "VER " . $TrID ++ . " MSNP8 CVR0 \r\n" );
get_msg( $socket, "^VER " );
 
snd_msg( $socket, "CVR " . $TrID ++ . " 0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS $login_id \r\n" );
get_msg( $socket, "^CVR " );
 
snd_msg( $socket, "USR " . $TrID ++ . " TWN I $login_id \r\n" );
$buff1 = get_msg( $socket, "^XFR " );
 
( $cmd, $trid, $xfr, $ns, $buff1 ) = split( / /, $buff1 );
( $ns, $port ) = split( /:/, $ns );
 
close( $socket );
 
$socket = msnp_connect( $ns, $port );
 
snd_msg( $socket, "VER " . $TrID ++ . " MSNP8 CVR0\r\n" );
get_msg( $socket, "^VER " );
 
snd_msg( $socket, "CVR " . $TrID ++ . " 0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS $login_id \r\n" );
get_msg( $socket, "^CVR " );
 
snd_msg( $socket, "USR " . $TrID ++ . " TWN I $login_id \r\n" );
$buff1 = get_msg( $socket, "^USR " );
 
( $cmd, $trid, $twn, $s, $param ) = split( / /, $buff1 );
 
$auth = "Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in=$login_id,pwd=$passwd,$param";
 
( $page, $response, @headers ) = get_https( 'loginnet.passport.com', 443, '/login2.srf', make_headers( Authorization => $auth ) );
 
( $buff1, $buff2 ) = split( /,from-PP='/, join( '', @headers ) );
( $buff1, $buff2 ) = split( /',ru=http:/, $buff2 );
 
snd_msg( $socket, "USR " . $TrID ++ . " TWN S $buff1 \r\n" );
get_msg( $socket, "^USR " );
 
snd_msg( $socket, "SYN " . $TrID ++ . " 0\r\n" );
get_msg( $socket, "^SYN " );
 
snd_msg( $socket, "CHG " . $TrID ++ . " NLN\r\n" );
get_msg( $socket, "^CHG " );
 
 
eval {
	local $SIG{ALRM} = sub { die "timeout" };
 
	alarm $timeout;
	while ( 1 ) {
		$buff1 =  get_msg( $socket, '.*' );
 
		if ( $buff1 =~ /^ILN/ ) {
			( $iln, $trid, $status, $account, $name, $param ) = split( / /, $buff1 );
			if ( $status eq 'NLN' ) {
				if ( $account eq $send_id ) {
					status_img( 'online.gif' );
					last;
				}
			}
		}
	}
	alarm 0;
};
 
alarm 0;
 
if ( $@ ) {
	if ( $@ =~ /timeout/ ) {
		status_img( 'offline.gif' );
		exit;
	}
}
 
snd_msg( $socket, "XFR " . $TrID ++ . " SB \r\n" );
$buff1 = get_msg( $socket, "^XFR " );
 
( $xfr, $trid, $sb_, $sb, $cki, $auth )  = split( / /, $buff1 );
( $sb, $port )  = split( /:/, $sb );
 
 
$socket2 = msnp_connect( $sb, $port );
 
snd_msg( $socket2, "USR " . $TrID ++ . " $login_id $auth \r\n" );
get_msg( $socket2, "^USR " );
 
snd_msg( $socket2, "CAL " . $TrID ++ . " $send_id \r\n" );
get_msg( $socket2, "^JOI " );
 
$buff1 = "MSG " . $TrID ++ . " U ";
$buff2 = "MIME-Version: 1.0\r\n" .
	"Content-Type: text/plain; charset=UTF-8\r\n" .
	"X-MMS-IM-Format: FN=; EF=; CO=; CS=; PF=\r\n" .
	"\r\n" .
	"$ENV{'REMOTE_HOST'}\r\n$ENV{'REMOTE_ADDR'}\r\n$ENV{'HTTP_REFERER'}";
 
if ( $message ne '' ) {
	$message = jcode($message)->utf8;
	$buff2 = "MIME-Version: 1.0\r\n" .
		"Content-Type: text/plain; charset=UTF-8\r\n" .
		"X-MMS-IM-Format: FN=; EF=; CO=; CS=; PF=\r\n" .
		"\r\n" .
		$message;
}
 
$buff1 = $buff1 . length( $buff2 ) . "\r\n" . $buff2;
 
snd_msg( $socket2, $buff1 );
snd_msg( $socket2, "OUT \r\n" );
 
exit;
 
sub msnp_connect {
	my ( $sv, $port ) = @_;
	my $socket;
	my $ip = inet_aton( $sv );
	my $sockaddr = pack_sockaddr_in( $port, $ip );
	socket( $socket, PF_INET, SOCK_STREAM, 0 );
	connect( $socket, $sockaddr );
	autoflush $socket 1;
	return $socket;
}
 
sub snd_msg {
	my ( $socket, $buff1 ) = @_;
	print $socket $buff1;
	print "TX: $buff1" if ( $Debug ) ;
}
 
sub get_msg {
	my ( $socket, $buff1 ) = @_;
	my $line;
 
	eval {
		local $SIG{ALRM} = sub { die "timeout" };
 
		alarm $timeout;
		while ( 1 ) {
			$line = <$socket>;
			print "RX: $line" if ( $Debug ) ;
			if ( $line =~ /$buff1/ ) { last; }
		}
		alarm 0;
	};
 
	alarm 0;
 
	if ( $@ ) {
		if ( $@ =~ /timeout/ ) {
			status_img( 'offline.gif' );
			exit;
		}
	}
 
	$line =~ s/[\r\n]//g;
	return $line;
}
 
sub status_img {
	my ( $buff1 ) = @_;
	my $buff2;
 
	#print "Content-type: image/gif\n\n";
	open FILE, $buff1;
	while ( read( FILE, $buff2, 4096 ) ) { print $buff2; }
	close FILE;
}
 
 
sub usage
  {
  print "Minimum arguments not supplied!\n\n";
  print "MSNP Status plugin adapted for Nagios\n";
  print "Usage: $0 <message> <recipient>\n\n";
  print "<message> = The message to send to the recipient.\n";
  print "<recipient> = The Recipient or System Administrator, whatelse.\n";
  exit -2
  }
les lignes que j'ai modifié : 29, 30
$login_id = 'usermonitor@hotmail.com';
$passwd = '*******';
j'ai testé dans les lignes : 35, 36 avec :
$ds = 'smtp.live.com';
$port = '587';
Toujours même erreur.

Merci.
inserm est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 12/11/2012, 15h31   #2
djibril
Responsable Perl et Outils

 
Avatar de djibril
 
Homme
Inscription : avril 2004
Messages : 13 530
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 33
Localisation : France

Informations forums :
Inscription : avril 2004
Messages : 13 530
Points : 31 717
Points : 31 717
Faut nettoyer les retour à la ligne dans ton programme. http://perl.developpez.com/faq/perl/...ChariotFichier
__________________
Pas de questions technique par messagerie privée (lisez les règles du forum Perl) et pour les nouveaux !
djibril est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 05h14.


 
 
 
 
Partenaires

Hébergement Web