Codebase list sendxmpp / 32407b7
Import Debian changes 0.0.8-1 sendxmpp (0.0.8-1) unstable; urgency=low * New upstream release. Guus Sliepen authored 19 years ago Thadeu Lima de Souza Cascardo committed 6 years ago
4 changed file(s) with 68 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
0 2005-05-07: version 0.0.8 released.
1 - add options to specify non-default ports
2 - updated documentation
3
4 2005-05-02: version 0.0.7 released / version 0.0.7.1.
5 - add --interactive mode to send from stdin line-by-line
6 - fix for typo ==> 0.0.7.1
7 - documentation updates
8
9 2004-12-07: version 0.0.6 released.
10 - fix for installation paths
11
012 2004-12-01: version 0.0.5 released.
113 - don't be too picky about passwords
214 - verbose output
00 # http://module-build.sourceforge.net/META-spec.html
11 #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
22 name: sendxmpp
3 version: 0.0.7.1
3 version: 0.0.8
44 version_from: sendxmpp
55 installdirs: site
66 requires:
0 sendxmpp (0.0.8-1) unstable; urgency=low
1
2 * New upstream release.
3
4 -- Guus Sliepen <guus@debian.org> Wed, 18 May 2005 11:21:14 +0200
5
06 sendxmpp (0.0.7.1-1) unstable; urgency=low
17
28 * New upstream release.
00 #!/usr/bin/perl -w
1
2 eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
3 if 0; # not running under some shell
14 #-*-mode:perl-*-
2 #Time-stamp: <2005-05-02 01:00:02 (djcb)>
5 #Time-stamp: <2005-05-07 19:24:09 (djcb)>
36
47 # script to send message using xmpp (aka jabber),
58 # somewhat resembling mail(1)
1417 use strict;
1518
1619 # subroutines decls
17 sub xmpp_login($$$$$$);
20 sub xmpp_login($$$$$$$);
1821 sub xmpp_send ($$$);
1922 sub xmpp_send_message($$$$);
2023 sub xmpp_send_chatroom_message($$$$$);
2932 sub main();
3033
3134 my # MakeMaker
32 $VERSION = '0.0.7.1';
35 $VERSION = '0.0.8';
3336 my $RESOURCE = 'sendxmpp';
3437 my $VERBOSE = 0;
3538 my $DEBUG = 0;
5457
5558 # login to xmpp
5659 my $cnx = xmpp_login ($$cmdline{'jserver'} || $$config{'jserver'},
60 $$cmdline{'port'} || $$config{'port'},
5761 $$cmdline{'username'} || $$config{'username'},
5862 $$cmdline{'password'} || $$config{'password'},
5963 $$cmdline{'resource'},
131135
132136 s/\#.*$//; # ignore comments in lines
133137
134 if (/([-\.\w]+)@([-\.\w]+)\s+(\S+)\s*$/) {
138 if (/([-\.\w]+)@([-\.\w:]+)\s+(\S+)\s*$/) {
135139 %config = ('username' => $1,
136140 'jserver' => $2,
141 'port' => 0,
137142 'password' => $3);
143
144 if ($config{'jserver'} =~ /(.*):(\d+)/) {
145 $config{'jserver'} = $1;
146 $config{'port'} = $2;
147 }
138148 } else {
139149 close CFG;
140150 error_exit ("syntax error in line $line of $cfg_file");
165175
166176 usage() unless (scalar(@ARGV));
167177
168 my ($subject,$file,$resource,$jserver,$username,$password,
178 my ($subject,$file,$resource,$jserver,$port,$username,$password,
169179 $message,$chatroom,$debug,$tls,$interactive,$help,$verbose);
170180 my $res = GetOptions ('subject|s=s' => \$subject,
171181 'file|f=s' => \$file,
186196 my $rcpt = $ARGV[0]
187197 or error_exit "no recipient specified";
188198
189 if ($message && $interactive) {
190 error_exit "cannot have both -m (--message) and -i (--interactive)\n";
191 }
199 if ($message && $interactive) {
200 error_exit "cannot have both -m (--message) and -i (--interactive)\n";
201 }
202
203 if ($jserver && $jserver =~ /(.*):(\d+)/) {
204 $jserver = $1;
205 $port = $2;
206 }
192207
193208 my %dict = ('subject' => ($subject or ''),
194209 'resource' => ($resource or $RESOURCE),
195210 'jserver' => ($jserver or ''),
211 'port' => ($port or 0),
196212 'username' => ($username or ''),
197213 'password' => ($password or ''),
198214 'chatroom' => ($chatroom or 0),
215231
216232 #
217233 # xmpp_login: login to the xmpp (jabber) server
218 # input: hostname,username,password,resource,tls,debug
234 # input: hostname,port,username,password,resource,tls,debug
219235 # output: an XMPP connection object
220236 #
221 sub xmpp_login ($$$$$$) {
222
223 my ($host,$user,$pw,$res,$tls,$debug) = @_;
237 sub xmpp_login ($$$$$$$) {
238
239 my ($host,$port,$user,$pw,$res,$tls,$debug) = @_;
224240 my $cnx = new Net::XMPP::Client(debuglevel=>($debug?2:0));
225241 error_exit "could not create XMPP client object: $!"
226242 unless ($cnx);
227243
228 my @res = $cnx->Connect(hostname=>$host,tls=>$tls);
244 my @res;
245 if (!$port) {
246 @res = $cnx->Connect(hostname=>$host,tls=>$tls);
247 } else {
248 @res = $cnx->Connect(hostname=>$host,port=>$port,tls=>$tls);
249 }
250
229251 xmpp_check_result("Connect",\@res,$cnx);
230252
231
232253 @res = $cnx->AuthSend('hostname' => $host,
233254 'username' => $user,
234255 'password' => $pw,
337358 my ($txt,$res,$cnx)=@_;
338359
339360 error_exit ("Error '$txt': result undefined")
340 unless (defined $res);
341
361 unless (defined $res);
362
342363 # res may be 0
343364 if ($res == 0) {
344365 debug_print "$txt";
432453 use <password> instead of the one in the configuration file
433454
434455 B<-j>,B<--jserver> <server>
435 use jabber server <server> instead of the one in the configuration file
456 use jabber server <server> instead of the one in the configuration file. Note that you can add :<port> to use a non-default port, ie. B<-j myjabber.org:1234>
436457
437458 B<-r>,B<--resource> <res>
438459 use resource <res> for the sender [default: 'sendxmpp']; when sending to a chatroom, this determines the 'alias'
474495 # my account
475496 alice@jabber.org secret
476497
477 ('#' and newlines are allowed like in shellscripts)
498 ('#' and newlines are allowed like in shellscripts). You can add :<port> to
499 the <host> if you need an alternative port, ie.
500
501 # account with weird port number
502 alice@myjabberhost.com:1234 secret
478503
479504 B<NOTE>: for your security, sendxmpp demands that the configuration
480505 file is owned by you and has file permissions 600.
487512
488513 $ echo "Dinner Time" | sendxmpp -r TheCook --chatroom test2@conference.jabber.org
489514
515 or to send your system logs somewhere, as new lines appear:
516
517 $ tail -f /var/log/syslog | sendxmpp -i sysadmin@myjabberserver.com
518
519 NOTE: be careful not the overload public jabber services
520
490521 =head1 SEE ALSO
491522
492523 Documentation for the L<Net::XMPP> module