This repository was intended to contain tools that allow you to quickly test and automate XMPP related things.
The sourceable bash script xmppcmd.bash
allows you to quickly
interact with raw xmpp or xmpp pubsub from the bash command line(or scripts).
Once sourced in bash, the function can be interacted with like shell
native commands. The functions are easily discoverable using the
xmpphelp
command. The usage of such functions can be learned by
using the -h
flag in the command arguments.
The other goal of this project was to create a tool that allowed the user to easily interact and learn the xmpp protocol. This is why the default debugging level is configured to emit the XML that is being sent and received. The tool automatically formats and color codes the XML stanzas in the terminal.
Looking though the script, you will notice that the functions build on each other in a structured manor. The level of abstraction from raw xmpp/xml to pubsub operations has been built up using the pipe operation. This same strategy can be used to create compact user defined functions. Users can add new functionality on-the-fly by combining parts of the core xmpp functions with readily accessible coreutils.
- xmppcmd.bash - BASH sourceable library of functions to control XMPP and XEP-0060
- xmppsend.c - The utility program that is used to send stanzas to the XMPP server and wait for responses
- xmpprecv.c - The utility program that is used to receive stanzas from the XMPP server
- Pretty print XML output
- BASH tab completions for node names and node item names (queries pubsub in background)
- Global config and local config options
-
Compilation
You need to build the xmppsend and xmpprecv executables for use by the xmppcmd.bash library.- The build system assumes that you have the development files for libstrophe installed.
- To install these on Debian, do a
sudo apt-get install libstrophe-dev
. - To install these on OSX with homebrew, do a
brew install libstrophe
and uncomment the two lines noted in the Makefile.
- To install these on Debian, do a
- A simple
make
in the xmpptools directory will build the binaries. If everything goes ok, you should see two new binaries, xmppsend and xmpprecv.
- The build system assumes that you have the development files for libstrophe installed.
-
Setting Defaults [optional]
Setting the default JID and password makes using this tool even more convenient. You can set a default JID and password in the xmpprc file. The variables of interest areDEFAULT_XMPP_USER
,DEFAULT_XMPP_HOST
, andDEFAULT_XMPP_PASS
. You will need to separate the JID into the USER and HOST parts.
Of course, I am obligated to tell you that saving passwords in plain text is a bad idea, so take necessary precautions.
One of the quickest ways to initialize the library is to supply the JID and Password on the commandline, as in the following example.
Load and initialize the utility.
. xmppcmd.bash "[email protected]" "mypassword"
Run any command in the library.
Example:
get_nodes
Below, I will show a few common commands.
Look in the examples
directory for scripting examples.
xmpphelp
Note: Running any command with the -h
argument will present it's usage options.
create craignode
publish craignode RandomItemId7 "<entry><head><title>Amazing Title</title></head><body>Some good website content</body></entry>"
. xmppcmd.bash bob
subscribe craignode
get_subscribers craignode
set_subscribers craignode tom none
get_affiliates craignode
set_affiliations craignode tom owner
get_vcard tom
set_vcard <<-EOF
<vCard xmlns="vcard-temp">
<FN>Craig Hesling</FN>
<EMAIL>
<USERID>[email protected]</USERID>
</EMAIL>
</vCard>
EOF
- Future work may include integrating more xml parsing functionality.
- Future work may include more serious bash completions
Pull requests are MORE than welcome. There are still so many XMPP functions and extensions to include.