version 1.6, 2006/10/04 23:53:26 |
version 1.7, 2006/10/17 08:09:12 |
|
|
# subroutines decls |
# subroutines decls |
sub xmpp_login($$$$$$$); |
sub xmpp_login($$$$$$$); |
sub xmpp_send ($$$); |
sub xmpp_send ($$$); |
|
sub xmpp_send_raw_xml($$); |
sub xmpp_send_message($$$$); |
sub xmpp_send_message($$$$); |
sub xmpp_send_chatroom_message($$$$$); |
sub xmpp_send_chatroom_message($$$$$); |
sub xmpp_logout($); |
sub xmpp_logout($); |
Line 183 sub parse_cmdline () { |
|
Line 184 sub parse_cmdline () { |
|
usage() unless (scalar(@ARGV)); |
usage() unless (scalar(@ARGV)); |
|
|
my ($subject,$file,$resource,$jserver,$port,$username,$password, |
my ($subject,$file,$resource,$jserver,$port,$username,$password, |
$message,$chatroom,$debug,$tls,$interactive,$help,$verbose); |
$message, $chatroom, $debug, $tls, $interactive, $help, $raw, $verbose); |
my $res = GetOptions ('subject|s=s' => \$subject, |
my $res = GetOptions ('subject|s=s' => \$subject, |
'file|f=s' => \$file, |
'file|f=s' => \$file, |
'resource|r=s' => \$resource, |
'resource|r=s' => \$resource, |
Line 196 sub parse_cmdline () { |
|
Line 197 sub parse_cmdline () { |
|
'interactive|i' => \$interactive, |
'interactive|i' => \$interactive, |
'help|usage|h' => \$help, |
'help|usage|h' => \$help, |
'debug|d' => \$debug, |
'debug|d' => \$debug, |
|
'raw|w' => \$raw, |
'verbose|v' => \$verbose); |
'verbose|v' => \$verbose); |
usage () |
usage () if ($help); |
if ($help); |
|
|
|
my @rcpt = @ARGV |
my @rcpt = @ARGV; |
or error_exit "no recipient specified"; |
|
|
if (defined($raw) && scalar(@rcpt) > 0) { |
if ($message && $interactive) { |
error_exit "You must give a recipient or --raw (but not both)"; |
error_exit "cannot have both -m (--message) and -i (--interactive)\n"; |
} |
} |
if ($raw && $subject) { |
|
error_exit("You cannot specify a subject in raw XML mode"); |
if ($jserver && $jserver =~ /(.*):(\d+)/) { |
} |
$jserver = $1; |
if ($raw && $chatroom) { |
$port = $2; |
error_exit("The chatroom option is pointless in raw XML mode"); |
} |
} |
|
|
|
if ($message && $interactive) { |
|
error_exit "Cannot have both -m (--message) and -i (--interactive)"; |
|
} |
|
|
|
if ($jserver && $jserver =~ /(.*):(\d+)/) { |
|
$jserver = $1; |
|
$port = $2; |
|
} |
|
|
my %dict = ('subject' => ($subject or ''), |
my %dict = ('subject' => ($subject or ''), |
'message' => ($message or ''), |
'message' => ($message or ''), |
'resource' => ($resource or $RESOURCE), |
'resource' => ($resource or $RESOURCE), |
Line 224 sub parse_cmdline () { |
|
Line 234 sub parse_cmdline () { |
|
'tls' => ($tls or 0), |
'tls' => ($tls or 0), |
'debug' => ($debug or 0), |
'debug' => ($debug or 0), |
'verbose' => ($verbose or 0), |
'verbose' => ($verbose or 0), |
|
'raw' => ($raw or 0), |
'file' => ($file or ($ENV{'HOME'}.'/.sendxmpprc')), |
'file' => ($file or ($ENV{'HOME'}.'/.sendxmpprc')), |
'recipient' => \@rcpt); |
'recipient' => \@rcpt); |
|
|
Line 281 sub xmpp_send ($$$) { |
|
Line 292 sub xmpp_send ($$$) { |
|
my ($cnx, $cmdline, $txt) = @_; |
my ($cnx, $cmdline, $txt) = @_; |
|
|
unless ($$cmdline{'chatroom'}) { |
unless ($$cmdline{'chatroom'}) { |
map { |
unless ($$cmdline{'raw'}) { |
xmpp_send_message ($cnx, |
map { |
$_, #$$cmdline{'recipient'}, |
xmpp_send_message ($cnx, |
$$cmdline{'subject'}, |
$_, #$$cmdline{'recipient'}, |
$txt) |
$$cmdline{'subject'}, |
} @{$$cmdline{'recipient'}}; |
$txt) |
} else { |
} @{$$cmdline{'recipient'}}; |
|
} |
|
else { |
|
xmpp_send_raw_xml ($cnx, $txt); |
|
} |
|
} |
|
else { |
map { |
map { |
xmpp_send_chatroom_message ($cnx, |
xmpp_send_chatroom_message ($cnx, |
$$cmdline{'resource'}, |
$$cmdline{'resource'}, |
Line 301 sub xmpp_send ($$$) { |
|
Line 318 sub xmpp_send ($$$) { |
|
|
|
|
|
# |
# |
|
# xmpp_send_raw_xml: send a raw XML packet |
|
# input: connection,packet |
|
# |
|
sub xmpp_send_raw_xml ($$) { |
|
|
|
my ($cnx,$packet) = @_; |
|
|
|
# for some reason, Send does not return anything |
|
$cnx->Send($packet); |
|
xmpp_check_result('Send',0,$cnx); |
|
} |
|
|
|
|
|
# |
# xmpp_send_message: send a message to some xmpp user |
# xmpp_send_message: send a message to some xmpp user |
# input: connection,recipient,subject,msg |
# input: connection,recipient,subject,msg |
# |
# |
Line 430 sub error_exit { |
|
Line 461 sub error_exit { |
|
sub usage () { |
sub usage () { |
|
|
print STDERR |
print STDERR |
"sendxmpp version $VERSION, Copyright (c) 2004,2005 Dirk-Jan C. Binnema\n" . |
"sendxmpp version $VERSION, Copyright (c) 2004, 2005 Dirk-Jan C. Binnema\n" . |
"usage: sendxmpp [options] <recipient1> [<recipient2> ...]\n" . |
"usage: sendxmpp [options] <recipient1> [<recipient2> ...]\n" . |
"or refer to the the sendxmpp manpage\n"; |
"or refer to the the sendxmpp manpage\n"; |
|
|
Line 450 sendxmpp - send xmpp messages from the c |
|
Line 481 sendxmpp - send xmpp messages from the c |
|
|
|
sendxmpp [options] <recipient1> [<recipient2> ...] |
sendxmpp [options] <recipient1> [<recipient2> ...] |
|
|
|
sendxmpp --raw [options] |
|
|
=head1 DESCRIPTION |
=head1 DESCRIPTION |
|
|
sendxmpp is a program to send XMPP (Jabber) messages from the commandline, not |
sendxmpp is a program to send XMPP (Jabber) messages from the commandline, not |
Line 457 unlike L<mail(1)>. Messages can be sent |
|
Line 490 unlike L<mail(1)>. Messages can be sent |
|
|
|
=head1 OPTIONS |
=head1 OPTIONS |
|
|
B<-f>,B<--file> <file> |
=over |
use <file> configuration file instead of ~/.sendxmpprc |
|
|
=item B<-f>,B<--file> I<file> |
|
|
B<-u>,B<--username> <user> |
Use I<file> configuration file instead of F<~/.sendxmpprc> |
use <user> instead of the one in the configuration file |
|
|
|
B<-p>,B<--password> <password> |
=item B<-u>,B<--username> I<user> |
use <password> instead of the one in the configuration file |
|
|
|
B<-j>,B<--jserver> <server> |
Use I<user> instead of the one in the configuration file |
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> |
|
|
|
B<-r>,B<--resource> <res> |
=item B<-p>,B<--password> I<password> |
use resource <res> for the sender [default: 'sendxmpp']; when sending to a chatroom, this determines the 'alias' |
|
|
|
B<-t>,B<--tls> |
Use I<password> instead of the one in the configuration file |
connect securely, using TLS |
|
|
|
B<-c>,B<--chatroom> |
=item B<-j>,B<--jserver> I<server> |
send the message to a chatroom |
|
|
|
B<-s>,B<--subject> <subject> |
Use jabber I<server> instead of the one in the configuration file. |
set the subject for the message to <subject> [default: '']; when sending to a chatroom, |
|
this will set the subject for the chatroom |
|
|
|
B<-m>,B<--message> <message> |
=item B<-r>,B<--resource> I<res> |
read the message from <message> (a file) instead of stdin |
|
|
|
B<-i>,B<--interactive> |
Use resource I<res> for the sender [default: 'sendxmpp']; when sending to a chatroom, this determines the 'alias' |
work in interactive mode, reading lines from stdin and sending the one-at-time |
|
|
|
B<-v>,B<--verbose> |
=item B<-t>,B<--tls> |
give verbose output about what is happening |
|
|
|
B<-h>,B<--help>,B<--usage> |
Connect securely, using TLS |
show a 'Usage' message |
|
|
|
B<-d>,B<--debug> |
=item B<-c>,B<--chatroom> |
show debugging info while running. B<WARNING>: This will include passwords etc. so be careful with the output! |
|
|
Send the message to a chatroom |
|
|
|
=item B<-s>,B<--subject> I<subject> |
|
|
|
Set the subject for the message to I<subject> [default: '']; when sending to a chatroom, this will set the subject for the chatroom |
|
|
|
=item B<-m>,B<--message> I<message> |
|
|
|
Read the message from I<message> (a file) instead of stdin |
|
|
|
=item B<-i>,B<--interactive> |
|
|
|
Work in interactive mode, reading lines from stdin and sending the one-at-time |
|
|
|
=item B<-w>,B<--raw> |
|
|
|
Send raw XML message to jabber server |
|
|
|
=item B<-v>,B<--verbose> |
|
|
|
Give verbose output about what is happening |
|
|
|
=item B<-h>,B<--help>,B<--usage> |
|
|
|
Show a 'Usage' message |
|
|
|
=item B<-d>,B<--debug> |
|
|
|
Show debugging info while running. B<WARNING>: This will include passwords etc. so be careful with the output! |
|
|
|
=back |
|
|
=head1 CONFIGURATION FILE |
=head1 CONFIGURATION FILE |
|
|
You may define a '~/.sendxmpprc' file with the necessary data for your |
You may define a 'F<~/.sendxmpprc>' file with the necessary data for your |
xmpp-account, with a line of the format: |
xmpp-account, with a line of the format: |
|
|
<user>@<host> <password> |
=over |
|
|
|
I<user>@I<server> I<password> |
|
|
|
=back |
|
|
e.g.: |
e.g.: |
|
|
# my account |
# my account |
alice@jabber.org secret |
alice@jabber.org secret |
|
|
('#' and newlines are allowed like in shellscripts). You can add :<port> to |
('#' and newlines are allowed like in shellscripts). You can add a I<host> (or IP address) if it is different from the I<server> part of your JID: |
the <host> if you need an alternative port, ie. |
|
|
# account with specific connection host |
|
alice@myjabberserver.com;foo.com secret |
|
|
|
You can also add a I<port> if it is not the standard XMPP port: |
|
|
# account with weird port number |
# account with weird port number |
alice@myjabberhost.com:1234 secret |
alice@myjabberserver.com:1234 secret |
|
|
|
Of course, you may also mix the two: |
|
|
|
# account with a specific host and port |
|
alice@myjabberserver.com;foo.com:1234 secret |
|
|
B<NOTE>: for your security, sendxmpp demands that the configuration |
B<NOTE>: for your security, sendxmpp demands that the configuration |
file is owned by you and has file permissions 600. |
file is owned by you and has file permissions 600. |
|
|
Line 536 file is owned by you and has file permis |
|
Line 602 file is owned by you and has file permis |
|
|
|
Documentation for the L<Net::XMPP> module |
Documentation for the L<Net::XMPP> module |
|
|
The jabber homepage: http://www.jabber.org/ |
The jabber homepage: L<http://www.jabber.org/> |
|
|
The sendxmpp homepage: http://sendxmpp.platon.sk |
The sendxmpp homepage: L<http://sendxmpp.platon.sk> |
|
|
=head1 AUTHOR |
=head1 AUTHOR |
|
|
sendxmpp has been written by Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>, and uses |
sendxmpp has been written by Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>, and uses |
the L<Net::XMPP> modules written by Ryan Eatmon. Current maintainer is |
the L<Net::XMPP> modules written by Ryan Eatmon. Current maintainer is |
Lubomir Host 'rajo' <rajo AT platon.sk>, http://rajo.platon.sk |
Lubomir Host 'rajo' <rajo AT platon.sk>, L<http://rajo.platon.sk> |
|
|
=cut |
=cut |