The project JXTA Shell provides an interactive environment to the project  JXTA platform. The Shell provides basic commands to discover peers and peergroups, to join and resign from peergroups, to create pipes between peers, and to send pipe messages. The Shell provides environment variables that permit binding symbolic names to project jxta platform objects.
Environment variables allow Shell commands to exchange data between themselves.  The shell command 'env' displays all defined environment variables in the  current Shell session.
The Shell creates a project JXTA InputPipe (stdin) for reading input from the keyboard, and a Jxta OutputPipe (stdout) to display informationon the Shell console. All commands executed by the Shell have their initial'stdin' and 'stdout' set up to the Shell's stdin and stdout pipes.
The Shell also creates the environment variable stdgroup that contains the  current project jxta Peer Group in which the Shell and commands are executed.
A new Shell can be forked within a Shell. The Shell -s command starts a new Shell with a new Shell window. The Shell can also read a command script file via the 'Shell -f myfile'.
 

A 'help' command is available to list the commands available. Type 'help<command>' to get help about a particular command. To exit the Shell,use the 'exit' command.
 
 
Command Description
cat displays on the stdout the content of a jxta object stored in a environment variable, currently limited to jxta types

jxta> mkadv -p apipe
jxta> cat env1
jxta> cat -p env1

chpgrp The chpgrp command is used to switch the default Shell peer group stdgroup variable to another group that was previously joined via a join command. The join command is used to join a peergroup.
After changing group, the Shell stdgroup variable is set to the value of the new peer group joined.
env env displays all the defined environment variables in the Shell seesion. The following environment variables are defined by default:
 
consin    = Default Console InputPipe
consout   = Default Console OutputPipe
stdout    = Default OutputPipe
stdin     = Default InputPipe
Shell     = Root Shell
stdgroup  = Default peer group
rootgroup = Default NetPeerGroup


Shell environement variables are defined as a result of executing Shell commands. The '=' operator can be used to assign value to a particular variable. For example myenv = mkmsg will assign a new message object to the myenv environment variable.
 

exit exits the current shell
exportfile exportfile exports the content of a Shell environment variable into an external file. The exported object is stored in the supplied filename argument.
If no variable name is given, the 'stdin' pipe is used to read data and saved them into the file.
exportfile is the reverse operation of importfile. The Shell environment variable is not deleted after the file is created

jxta> exportfile -f /home/userdir/filename peer0
jxta> importfile -f  /home/userdir/filename envpeer
 

get get retrieve the tag body of a message. JXTA messages are composed a set of tag body, each identified with an unique tag name A message tag name is supplied to command to specify which tag body to extract.
 
jxta> pipeadv = mkadv -p mypipe
jxta> inpipe = mkpipe -i pipeadv

jxta> Shell -s


in the new shell window
 

jxta> opipe = mkpipe -o pipeadv
jxta> mymsg=mkmsg
  jxta> importfile -f PlatformPeerGroup file1
jxta> put mymsg mytag file1
jxta> send opipe mymsg


back in the prev shell window
 
 

jxta> msg = recv inpipe


at this point you can cat  msg, which will display the tag, and the msg, or do the following  which will retrieve the msg and insert into the env. variable data
 

jxta> data = get msg mytag
jxta> cat -p data
groups discovers peer groups by propagation or at a specified peer location. By default groups lists all the peer groups   known (cached) by the local peer. The -r option is used to send  a propagate request to find new peer groups. groups stores results  in the local cache, and inserts advertisement(s) into the environment,  using the default naming: groupX where X is a growing integer  number.
 
jxta> groups
jxta> groups -r
jxta> groups
jxta> mkpgrp soccer


on another peer
 

jxta > groups -r -aName -vsoccer
jxta> groups   (should display discovered soccer group)
help Displays Shell help, and available commands
importfile imports an external structured document into the  shell environment
 
jxta> importfile -f  /home/userdir/afile envfile
jxta> cat envfile
join The join command is used to join a peergroup that was created via a mkpgrp command or using an advertisement that was previously discovered.
In order to join a group, the group needs to have been discovered or created first. If no argument is given, join lists all the existing groups and their status (join, unjoined) and the current group on the local peer. After a group was joined successfully, the 'PG@<group name>' environment variable is created. This variable holds the group info. When joining a new peer group, the new peer group is advertised in the NetPeerGroup. No hierarchy of peer groups is supported.

create a peergroup:
 

jxta> mkpgrp volleyball
jxta> join volleyball
identity: nobody


When joining a peer group an identity can be asked depending on the peer group mebership. The identity may require a password. In the above case a null authenticator was used with the 'nobody' identity.

Leave the peer group
 
 

jxta> leave
jxta> groups -r -a Name -v soccer
jxta> groups


make note of the env variable associated with group soccer
 

jxta> join -d group#
 

leave The leave command is used to leave a group that was previously joined via a join command. The join command is used to join a peer group.
After leaving the group, the Shell stdgroup variable is reset to the value of the default rootgroup variable (NetPeerGroup).
Before a user can use the group again, the user will have to rejoin the group via the join command.
 
  jxta>mygroupadv = mkadv -g mygroup
  jxta>mkpgrp -d mygroupadv mygroup
  jxta>join mygroup
  jxta>leave
mkadv mkadv creates a peer group or pipe advertisement from a document stored in a shell environment variable. A specific type can be given for the pipe (TBD). A symbolic name can be associated with the advertisement. This name can be used to search for the advertisement. A name must be supplied when creating a new group advertisement. This is the name of the peer group.
-p for a pipe advertisement
-g for a groups advertisement
-d to specify a document to use in creating the advertisement object
jxta> agroupadv = mkadv -g -d fileimported
jxta> mkpgrp -d agroupadv mygroup
mkmsg creates msg object to use for sending or receiving pipe messages
see get example
mkpgrp mkpgrp creates a new peer group using the supplied peer group advertisement  If no advertisement is provided, the command will create a clone of the NetPeerGroup peer group with the name specified.The  command mkadv -g is used to create a peer group advertisement The environment  variable PG#<group name> is created to store the the new group info.  The new peer group is advertised in the NetPeerGroup. All peer groups are created in the NetPeerGroup which acts like a world peer group. Every peer group can be found in this group.
 
jxta> mkpgrp soccer
jxta> group_from_a_imported_file= mkpgrp -d file1
mkpipe mkpipe creates an input pipe or an output pipe from a given pipe advertisement document. In order for pipes to communicate an input and output pipe needs to be created with the same pipe advertisement.  Pipe advertisements are structured documents that contains at least the unique  pipe Id. The pipe Id uniquely identifies a pipe in the JXTA world. Pipesare  not localized or binded to a physical peer. Pipe connections are established  by searching for pipe advertisements and resolving dynamically the location  of an input pipe object binded to that advertisement. An input pipe can be  binded to the same pipe advertisement on multiple peers transparently tothe  output pipe. The output pipe does not need to known on which physicalpeer  the input pipe is located. To communicate with the pipe, the outputpipe needs  to search for the input pipe that binds that advertisement.

see get example
 

more more  - page through a Shell object
peerconfig peerconfig is used to re-configure a peer. The command forces the platform to show a configuration dialog the next time it starts.
After the command is run the platform need to be restarted.
peerInfo Use to get information about other peers within a peer group or at a specified peer location. The default peerinfo option lists only the peerinfo advertisements already known by the peer. The '-r' option is used to send a propagate request to find information about new peers.
peerinfo stores results in the local cache, and inserts advertisement(s) into the environment, using the default naming: peerinfoX where X is a growing integer number.
 
jxta> peerinfo -r
jxta> peerinfo
jxta> cat peerinfo1
peers use peers to discover other peers within a peer group or at a specified peer location. Running peers command with no options lists only the peers already known by the peer (cached).The '-r' option is used to send a propagate request to find new peers. peers command stores results in the local cache, and inserts advertisement(s) into the environment, using the default naming: peerX where X is a growing integer number.
 
jxta> peers
jxta> peers -r
jxta> peers
put put store a document into the body of message.JXTA  messages are composed a set of tag body, each identified with an unique tag  name A message tag name is supplied to specify which tag name is used to store  the document. On the receiving end the document can be retrieved viathe 'get'  command.
 
jxta> importfile -f /home/username/myfile mydata
jxta> msg = mkmsg
jxta> put msg mytag mydata
recv recv receives a message from an input pipe. The input pipe needs to have been previously created. A timeout in seconds can be given. If no timeout is given, the call will block until a message is received. A timeout of zero corresponds to a non-blocking call.

see get example

search search for an advertisement document that has a matching (tag,value)  field. Documents are searched either in the local peer cache or remotelly within the reachable peer group members. Remote search is done asynchronous, matching documents are brought up locally. There is no guarantee that a published advertisement will be found. A best effort is made, but the peer that has published the advertisement may be unavailable at the time the search is performed. The search capability is rudimentary.It only handles first level tags in a document. The default is to serach document locally.
 
jxta> search -r name identity
jxta> search name indentity
send send - send a message into a pipe

see get exmaple

setenv setenv - set an environment variable
share share an advertisement document in the current peer group.
The document is made visible to all the members of the peer group.
   Advertisements are XML documents that can represent any JXTA objects advertisement,  environment variables). Documents are searched either in the local peer cache  or remotely via the search command.

jxta> share mydoc
 

Shell Start a new shell
 
jxta> Shell -s   (start a new shell in a new window)
jxta> Shell -s -f  /home/username/batchfile  (starts a new shell in new window and executes
batchfile)
talk The talk command implements a simple instant  messaging command  where two users on two remote peers can exchange messages.
Messages are displayed on the Shell stdout. In order  to use talk.  The user needs to register himself. This is done via the following steps:

   Step 1: Register via  talk -register <username> command. This command
         creates a Talk advertisement for that user. This has to
          be done only once, the first time the user registers with
          talk. The system remembers it accross reboot.

Step 2: Login  via  talk -login <username> command. This command
        logs the user and starts a listener daemon.This has to
        to be done everytime the peer is restarted.

Step 3: User can talk to another user via the command
          talk -u <myusername> <destusername> .  This command will prompt the user
        to enter the message he/she wants to send
 

jxta> talk -register user1
jxta> talk -login user1


   in another Shell window, or on another peer

  jxta> talk -register user2
  jxta> talk -login user2
  jxta> talk user1
To stop receiving any more talk messages. The user can stop the talk listener daemon by entering the command 'talk -logout <username>'"
wc wc counts the number of newlines, whitespace-separated  words,  and characters in the given shell object, or in the standard  input pipe if no object is specified.  It writes one line of countsto  the output pipe.  The counts are written in the order: lines, words,  characters.
By default, wc writes all three counts.  Options can specify that only certain counts be written.  Options do not undo others previously given, so 'wc -c -l' writes both the character count and the line count.
 
  jxta>peers  | wc
whoami whoami displays information about a peer or a peer group.  With no option, whoami returns information about the local peer. The '-g'  option returns information about the current peer group joined.
  By default the Shell is brought up in the NetPeerGroup group. Peers do not  have name. A user can assign a symbolic name to a peer via the peerinfo command.  There is no guarantee that the name is unique. Only the peerId and the peer group  ID are guaranteed to be unique.
 
 
version displays the current version of the shell, build number and date