aterm (Mediaflux command line)
Mediaflux Terminal (aterm) is a command-line application. It can be run from the web, or can be downloaded and run as a Java application which has GUI mode (the default) whereby it presents a GUI into which you type service commands. In GUI mode it supports features such as command history and tab completion. It can also be run in a no-GUI mode, most useful for scripting.
Aterm uses the HTTPS protocol so transmission of data is encrypted and provides good data integrity guarantees.
- 1 Official Guide
- 2 Running the web-based aterm
- 3 Running the Java aterm app in GUI mode
- 4 Running the Java aterm in a terminal (no GUI)
- 4.1 Tab completion
- 5 Download and upload with aterm
- 5.1 Basic commands
- 5.1.1 Ping
- 5.1.2 Download
- 5.1.3 Upload (import)
- 5.2 Examples
- 5.2.1 Downloads
- 5.2.2 Uploads
- 5.2.3 Downloading previous versions of an asset
- 5.1 Basic commands
- 6 Generate a download shareable based on a query
- 7 Import data by HTTP URL
- 8 Mediaflux API
- 9 Scripting with Mediaflux aterm
- 10 Getting aterm
- 11 Main classes
- 12 Configuration file
- 13 Java command line arguments
- 14 Scripting based on arc.mf.aterm.AppSelector
- 15 Scripting based on arc.mf.command.Execute
Official Guide
There is an official guide available for using aterm. Go to Mediaflux Desktop, then Help and Guides. You can browse the guide online or download it as a PDF.
Running the web-based aterm
The web aterm can be run from this URL: https://mediaflux.researchsoftware.unimelb.edu.au/aterm/
For help on using the web aterm, press the help button in the top right of the web aterm window. Service documentation is also available.
Running the Java aterm app in GUI mode
The Aterm Java application can be downloaded from any Mediaflux server (the download URL for our server is https://mediaflux.researchsoftware.unimelb.edu.au/mflux/aterm.jar). Run the aterm application by double clicking on it. Enter the appropriate Mediaflux server HTTPS details (which it will remember subsequently).
Service | Protocol | Host | Port |
|---|---|---|---|
UniMelb Primary | https | mediaflux.researchsoftware.unimelb.edu.au | 443 |
Also check the Allow Untrusted check box.
Login
Mediaflux requires the triple of (domain, username and password) to log in. All the Mediaflux login screens show these fields.
University of Melbourne Central (Active Directory) Account
You can login to Mediaflux directly with your University of Melbourne institutional credential
Enter unimelb (staff accounts) or student (student accounts) into the Domain entry field
Enter your usual institutional username (for the user field) and password (for the password field and click Sign In).
This example is for a unimelb staff account (the full server name, obscured here, is mediaflux.researchsoftware.unimelb.edu.au)
Local Account
If your account is a local account (i.e. not using your institutional account), you will have been provided with the details for domain, user and password.
Here is an example for a local account (the full server name, obscured here, is mediaflux.researchsoftware.unimelb.edu.au)
Running the Java aterm in a terminal (no GUI)
You can also run the Aterm Java application without the GUI - a CLI version good for non-windowing environments. You can do this manually, using the locally installed java runtime:
Download the Java application from the URL for our server : https://mediaflux.researchsoftware.unimelb.edu.au/mflux/aterm.jar
Unix Example
Create a config file in $HOME/.Arcitecta/mflux.cfg holding the server and user details (domain and user name)
Execute the jar file with Java
java -jar -Dmf.cfg=$HOME/.Arcitecta/mflux.cfg /path/to/aterm.jar nogui
Enter your password and then you will get the CLI Aterm shell into which you can enter commands
Or you can use a wrapper script that we have created to do this more conveniently. You can download the wrapper by itself or as part of a release of unimelb-mf-scripts which includes a Java runtime. If you use the wrapper script, the equivalent to the command above would be:
cd unimelb-mf-clients/bin/unix
./aterm
You can also pass a command directly to aterm and have it executed non-interactively. Here is an example, using the wrapper script:
cd unimelb-mf-clients/bin/unix
./aterm "server.uuid"
:uuid "1128"If you specify all of the details required to log in within your ~/.Arcitecta/mflux.cfg file (by either including your password or using a secure identity token), you will be able to redirect the output to a file (useful to capture large outputs for later processing). Ensure that the ~/.Arcitecta/mflux.cfg file is appropriately protected if you do this on a multi-user system with e.g. chmod go-rwx ~/.Arcitecta/mflux.cfg. If you don't have everything required to log in non-interactively in your config file, you will see this error: java.lang.AssertionError: Interactive console disabled.
cd unimelb-mf-clients/bin/unix
./aterm "server.uuid" > test.txt
cat test.txt
:uuid "1128"By default, the nogui version of aterm does not provide any command line history which can be quite painful if you are using it interactively. However, you can add this functionality using a wrapper for GNU readline, like rlwrap or rlfe. rlwrap even remembers your command line history from one invocation of aterm to the next.
java -jar -Dmf.cfg=$HOME/.Arcitecta/mflux.cfg ~/.Arcitecta/aterm.jar nogui # cannot use arrow keys on keyboard to access previously executed commands
quit
sudo apt install rlwrap
rlwrap java -jar -Dmf.cfg=$HOME/.Arcitecta/mflux.cfg ~/.Arcitecta/aterm.jar nogui # can use arrow keys to access command history
sudo apt install rlfe
rlfe java -jar -Dmf.cfg=$HOME/.Arcitecta/mflux.cfg ~/.Arcitecta/aterm.jar nogui # can use arrow keys to access command historyTab completion
You can have rlwrap perform tab completion of aterm commands. To do this, you need to generate a list of all available commands, save this in a file, and pass this file to rlwrap when you invoke it. Note that you will have a different list of available commands depending on your permissions within the system, so it's best to generate this list with your most privileged account. For example:
# ensure you can log in non-interactively by specifying password (see above)
vim ~/.Arcitecta/mflux.cfg
# generate a list of all aterm commands and save to a file
java -jar -Dmf.cfg=$HOME/.Arcitecta/mflux.cfg ~/.Arcitecta/aterm.jar nogui "help" | head -n -2 | tail -n +2 | sed 's/^\t//' > ~/aterm-cmds.txt
# you can now remove the password from your configuration file
vim ~/.Arcitecta/mflux.cfg
# Now invoke aterm with rlwrap, loading the command list for tab completion.
# You need the '-c' option so that the commands are not split on the '.' character.
rlwrap -c -f ~/aterm-cmds.txt java -jar -Dmf.cfg=$HOME/.Arcitecta/mflux.cfg ~/.Arcitecta/aterm.jar nogui
Aterm can also be run without the Java GUI for scripting purposes. See Scripting with Mediaflux aterm.
Download and upload with aterm
You can use aterm commands to upload and download data over the HTTPS protocol. This allows for secure, multi-threaded upload with good data integrity guarantees. See aterm (Mediaflux command line) for information on acquiring and logging in to aterm.
Basic commands
When you first log in to aterm, you will be presented with the command prompt. You can use the help command to get a list of available commands, and help commandname to get specific help on a command. Some unix-like commands are available. Some examples that are worth running to get started:
help ls
help cd
help pwd |
In aterm, namespaces present just like directories on a regular filesystem. On the University of Melbourne server, generally projects appear in the /projects namespace.
cd /projects
ls
cd proj-demonstration-1128.4.15 |
While the ls command allows you to work with relative paths, most commands in Mediaflux require absolute paths (which specify a location starting at the root, e.g. /projects/proj-demonstration-1128.4.15). When your project is created, you will be advised what its path is. You will only see namespaces that you have access to.
Ping
A really useful capability is the ability to ping the Mediaflux server to measure the bandwidth available from your client to the Mediaflux server, similar to the unix perf tool. Here is an example:
ping 100MB |
Download
The download command allows you to download namespaces (directories) or assets (files) to your local filesystem. It only downloads assets that have content (not zero-size).
help download |
Upload (import)
The import command allows you to upload directories or files from your local machine to Mediaflux as new namespaces/assets.
help import |
Examples
In the following examples:
-ncsr 2 means use two simultaneous threads (don't use too many you will exhaust your bandwidth)
-filename-collisions skip directs the command to skip files you already downloaded (so you can restart).
The last argument is the path on the local file system where the data will be saved.
Downloads
Recursively download an entire namespace (and its children).
download -ncsr 2 -namespace "/projects/proj-demo-1128.1.3/baskets" -filename-collisions skip "/Users/nebk/data/baskets" |
Download assets from a particular namespace which were created more recently than 7 days ago (uses the where query clause)
download -ncsr 2 -where "namespace>=/projects/proj-demo-1128.1.3/baskets and ctime>='TODAY-7DAY'" -filename-collisions skip "/Users/nebk/data/baskets" |
Uploads
Create a new namespace (directory) and recursively upload the contents of a local directory into it.
mkns "/projects/proj-demo-1128.1.3/panniers"
import -ncsr 2 -namespace "/projects/proj-demo-1128.1.3/panniers" "/Users/nebk/data/panniers" |
Upload the contents of a local directory into an existing namespace and compress the files into a zip archive (compression level 5) on-the-fly. So the result is a single asset holding all the recursive contents of the local directory. You can download and unpack that asset with, e.g. unzip
import -archive zip:5 -ncsr 2 -namespace "/projects/proj-demo-1128.1.3/panniers" "/Users/nebk/data/panniers" |
Downloading previous versions of an asset
You can download previous versions of assets using aterm commands. For example, this command will download two versions of hello.txt. It uses a TCL for loop. This will work in the Java version of aterm (aterm GUI or aterm CLI) but not web aterm.
for {set a 1} {$a < 3} {incr a} { asset.content.get :id path=/projects/proj-demonstration-1128.4.15/hello.txt -version $a :out "hello.$a.txt" } |
Generate a download shareable based on a query
Log into Aterm
Open Web Aterm in your browser, and log in.
Construct the query string
If you want to share only the *.txt files in your Mediaflux directory: /projects/proj-test-1247.5.1/data with some external collaborators. Firstly, you need to construct a Mediaflux query string to select those *.txt files. You can execute asset.query service in Aterm to validate your query string:
asset.query :action get-path :where namespace>='/projects/proj-test-1247.5.1/data' and name ends with '.txt" |
The above command should list all the txt files in /projects/proj-test-1247.5.1/data
Create a download shareable based on the query
Once you have query string ready, you can execute asset.shareable.download.create service in Aterm to create a shareable and send the invitation (with the download link) to your collaborators:
asset.shareable.download.create :name "Txt Files" :valid-to today+3day :invitation < :email THE_RECIPIENT@YOUR-COLLABORATORS.ORG :name "THE RECIPIENT" > :where namespace>='/projects/proj-test-1247.5.1/shared-data' and name ends with '.txt' |
In the above command,
it creates a download shareable base on query string "namespace>='/projects/proj-test-1247.5.1/shared-data' and name ends with '.txt'"
it sends invitation email (with the link) to your collaborator (:invitation < :email THE_RECIPIENT@YOUR-COLLABORATORS.ORG :name "THE RECIPIENT" >)
the link expires in 3 days. (:valid-to today+3day) You can also specify the exact date, for example,
:valid-to 31-May-2023
More details about asset.shareable.download.create, run help asset.shareable.download.create in Aterm
help asset.shareable.download.create |
Import data by HTTP URL
Certain Mediaflux services, such as asset.create or asset.set can be used to directly import remote data files by http:// or https:// URL. This allows importation of content from a remote server directly into Mediaflux without needing to download the data to your local workstation first.
Import remote HTTP content using Mediaflux web aterm
You can use asset.create service to import remote HTTP content using Mediaflux aterm.
Open Mediaflux Web aterm
Open Mediaflux Web aterm: https://mediaflux.researchsoftware.unimelb.edu.au/aterm/ in your browser and login with your credentails: domain, username, and password.
Create asset from remote HTTP content
Run the following service to create an asset from remote content by HTTP URL:
Create asset from remote http content
asset.create :namespace /projects/proj-demonstration-1128.4.15 :name 2_skull_ct.zip :url https://medimodel.com/wp-content/uploads/2021/03/2_skull_ct.zip |
The command may take a while to complete as the remote content is fetched to the Mediaflux server. The id of the newly created asset will be returned. See the screenshot below:
You can cd into the namespace and run ls to list the assets:
And you can run asset.get service to get the details about the asset:
See the Mediaflux aterm page for more information on the capabilities of the web aterm.
Import remote HTTP content using aterm script
Aterm is also available as a Java application that you can run on your local machine. It's also available as a module Spartan HPC. Installing through either of these methods includes a script called aterm which can be used to execute the same service to import HTTP content.
If you are on Spartan HPC, you can load the unimelb-mf-clients module and run the aterm command below to import remote conntent from HTTP URL to your Mediaflux project.
Call asset.create service to import remote HTTP content on Spartan HPC
module load unimelb-mf-clients
aterm asset.create :namespace /projects/proj-YOUR_PROJECT-1128.4.xxx :name data.zip :url https://remote-server/path/to/data.zip |
Mediaflux API
Mediaflux can be accessed programmatically via various Application Programming Interfaces (APIs). Mediaflux is a service-oriented architecture - pretty much everything you do with it executes a service in the Mediaflux server. However, to access those services, you need a client, such as Mediaflux Desktop (web browser interface) (browser based client) or Mediaflux Explorer (beginner friendly) (Java GUI client).
It's also possible to reach all of the service layer with clients via:
Java - the Java API is provided by Arcitecta through a .jar file. One can write and execute Java clients that use this directly.
Bash - a Java client is generally wrapped in a script for execution. It is very common to wrap them in a Unix script via a shell like Bash.
A specific Java client that is supplied with Mediaflux is aterm (Java command line client). It is also very common to wrap aterm commands in Bash scripts for convenience, or even just type them dynamically into a Bash shell terminal window.
Tcl - Tcl scripts can be executed via the aterm client. aterm has a built in Tcl interpreter so this is a powerful and easy way to script with the Mediaflux service layer. Tcl scripts can be sourced from the aterm GUI or run using aterm in nogui mode.
Python - a Python module is provided by Research Computing Services. It allows native Python scripting to work with the Mediaflux API
Bash Scripting with aterm
The first step is to install a Java 8 JDK on your client computer (if it is not already installed). You can get Java from http://www.oracle.com/technetwork/java/javase/downloads/index.html.
Now download and install the aterm.jar file. See the Software Downloads page.
By including your full credential in the aterm configuration file, you can now issue aterm directives from the Unix shell (interactively or in a script)
Now you can use aterm on the command line (try issuing a command like
server.uuid)
Tcl Scripting with aterm
Run the aterm application
Write your Tcl script
Execute the script with aterm
ATERM> source <path to script>/<name of script>.tcl
Scripting with Mediaflux aterm
aterm is a Mediaflux terminal client application, distributed in the Java jar package aterm.jar. In addition to the aterm graphical user interface (GUI), aterm.jar provides classes for issuing commands directly to the Mediaflux server from the command line allowing execution of services and transfer of data to/from the Mediaflux server. In this way it can be used for scripting.
You can either call the classes directly or use one of the wrappers available.
Getting aterm
See the Software Downloads page. You can also download aterm.jar using the unimelb aterm wrapper script.
Main classes
In aterm.jar file, there are two main classes can be used to communicate with a Mediaflux server:
arc.mf.aterm.AppSelector (default)
arc.mf.command.Execute
These are the entry points used by the wrapper scripts, and can also be called directly on the command line.
Configuration file
The configuration file specifies the connection parameters that aterm will use. If you're running aterm.jar directly, a configuration file can be passed to aterm with the -Dmf.cfg=path_to_config_file java argument. The wrapper scripts generally take care of this for you; refer to each script for the method used.
Java command line arguments
When running aterm directly, the values specified in the configuration file can also be passed as Java command line arguments.
argument | meaning |
|---|---|
-Dmf.host=$MFLUX_HOST | mediaflux server host address |
-Dmf.port=$MFLUX_PORT | mediaflux server port number |
-Dmf.transport=$MFLUX_TRANSPORT | mediaflux server transport: http https or tcp/ip |
-Dmf.cfg=$MFLUX_CFG | configuration for mediaflux server details. Either this or combination of mf.host, mf.port and mf.transport must be supplied |
-Dmf.sid=$MFLUX_SID | mediaflux session id. It is generated by the logon process. then it is used for any subsequent service calls |
-Dmf.result=$MFLUX_OUTPUT | mediaflux service output format. can be: shell or xml |
Scripting based on arc.mf.aterm.AppSelector
This is the default entry point (main class) for aterm.jar. Each invocation will create a new user session on the Mediaflux server which is not destroyed when it exits (the session will be eventually disappear after expiry). For this reason it is recommended to use arc.mf.command.Execute or source a TCL script if you are running many commands (e.g. in a loop).
java -cp /path/to/aterm.jar arc.mf.aterm.AppSelector |
This is equivalent to:
java -jar /path/to/aterm.jar |
Unimelb wrapper script for arc.mf.aterm.AppSelector
Research Computing Services provides a script wrapper (called
aterm) for aterm to make this process a little easier.This wrapper is provided as part of the unimelb-mf-clients GitLab repository. Download directly from GitLab.
Further details on the aterm wrapper script are available here, including examples of executing the script.
The wrapper will fetch aterm.jar for you as well so no need to download it.
To work with the aterm script wrapper in this way you first need to setup a configuration file to tell aterm which server and which Mediaflux account to use.
Arcitecta wrapper script for arc.mf.aterm.AppSelector
A shell script based on main class: arc.mf.aterm.AppSelector which makes issuing commands more convenient can be found at Mediaflux installation directory $MFLUX_HOME/bin/unix/aterm and is included here:
opt/mediaflux/bin/unix/aterm
#!/bin/sh
#
# Aterm shell commands - enables the aterm command line terminal.
#
# Usage:
#
# ./aterm
# ./aterm <service>
# ./aterm <script>
#
# See if the location of aterm has been set.
if [ -z $MFLUX_ATERM ]
then {
# If not, then assume relative to the location of this shell script
# which is distributed one level below the aterm.jar
MFLUX_ATERM=`dirname "$0"`/../aterm.jar
}
fi
# Have we been supplied with the location of a configuration file
# that specifies the host, etc. If so, use that.
#
# This file has the form:
#
# host=<host>
# port=<port>
# transport=[http|https]
# #
# domain=<domain>
# user=<user>
# password=<password>
# # Authentication can be via a token
# # aterm> secure.identity.token.create :role -type role read-only
# # :token -actor-type "identity" -actor-name "172" "IykJZOEx89kdT331Yq5mgUHrpvF98v6ykNxvZCKpMydWhMLtZSt33ZuoqgANThis-is-A-Fake-Tokenc8F8waEzCyOjhLXw2ADhCCyaa566V249SlWg4pPJcyuHzTv801707"
# #
# token=IykJZOEx89kdT331Yq5mgUHrpvF98v6ykNxvZCKpMydWhMLtZSt33ZuoqgANThis-is-A-Fake-Tokenc8F8waEzCyOjhLXw2ADhCCyaa566V249SlWg4pPJcyuHzTv801707
#
# All are optional - if not specified, then aterm.jar will ask for them.
#
if [ -z $MFLUX_CFG ]
then {
# Execute without configuration. Will be prompted for connection and
# credential details
java -jar $MFLUX_ATERM nogui $*
} else {
# Use the supplied configuration
java -jar -Dmf.cfg=$MFLUX_CFG $MFLUX_ATERM nogui $*
}
fi
Examples
java -cp /path/to/aterm.jar arc.mf.aterm.AppSelector nogui server.uuid
java -jar /path/to/aterm.jar nogui server.uuid
java -jar /path/to/aterm.jar nogui asset.create :name test.txt :namespace /test :in file:/tmp/test.txt |
Scripting based on arc.mf.command.Execute
arc.mf.command.Execute is is another entry point (main class) in aterm.jar.
java -cp /path/to/aterm.jar arc.mf.command.Execute <mediaflux-command> |
This main class can be used to start a system session, and use the session for subsequent service calls.
The script below authenticates with user password, and returns the server uuid. The domain, user and password can be specified in the configuration file or on the command line as in the script below.
#!/bin/bash
MFLUX_SID=`java -cp /path/to/aterm.jar -Dmf.cfg=$MFLUX_CFG arc.mf.command.Execute logon YourDomain YourUsername YourPassword`
MFLUX_UUID=`java -cp /path/to/aterm.jar -Dmf.cfg=$MFLUX_CFG -Dmf.sid=$MFLUX_SID -Dmf.result=shell arc.mf.command.Execute server.uuid`
echo $MFLUX_UUID
java -cp /path/to/aterm.jar -Dmf.cfg=$MFLUX_CFG -Dmf.sid=$MFLUX_SID arc.mf.command.Execute logoff |
Logging on
By passing command line arguments we can log on and store the MFLUX_SID. We pass this to subsequent executions to avoid logging on again for each command that we execute.
Password authentication
MFLUX_SID=`java -cp /path/to/aterm.jar -Dmf.cfg=$MFLUX_CFG -cp $MFLUX_ATERM arc.mf.command.Execute logon $MFLUX_DOMAIN $MFLUX_USER $MFLUX_PASSWORD` |
Secure identity token authentication
Note that arc.mf.command.Execute cannot pull the token and token.app values from the config file. To authenticate with a token, -token and -app arguments should be used.
MFLUX_SID=`java -cp /path/to/aterm.jar -Dmf.cfg=$MFLUX_CFG -cp $MFLUX_ATERM arc.mf.command.Execute logon -token $MFLUX_TOKEN -app $MFLUX_TOKEN_APP` |
Arcitecta wrapper script for arc.mf.command.Execute
A shell script based on main class arc.mf.command.Execute which makes issuing mediaflux commands more convenient can be found at Mediaflux installation directory $MFLUX_HOME/bin/unix/mfcommand and is included here:
/opt/mediaflux/bin/unix/mfcommand
#!/bin/sh
# file name mfcommand
# MFLUX_HOME is the location of the mediaflux installation to be
# controlled by this script.
#MFLUX_HOME=/home/mediaflux/mflux
# PATH is the location of the directory containing the Java
# executable. Edit the path to point to the correct Java version.
#PATH=$PATH:/usr/java/j2re1.4.2_01/bin
check_env() {
if [ -z "$MFLUX_ATERM" ]
then {
if [ -z "$MFLUX_HOME" ]
then {
echo "The environment variable MFLUX_HOME has not been defined.";
echo "This environment variable must be set to the root of the Mediaflux";
echo "installation."
exit 1;
}
fi
MFLUX_ATERM=$MFLUX_HOME/bin/aterm.jar
}
fi
# If there is an external configuration, then we'll use that, otherwise ask for the
# host, port etc.
if [ -z "$MFLUX_CFG" ]
then {
if [ -z "$MFLUX_HOST" ]
then {
echo "The environment variable MFLUX_HOST has not been defined.";
echo "This environment variable must be set to the DNS or IP address of"
echo "the server.";
exit 1;
}
fi
if [ -z "$MFLUX_PORT" ]
then {
echo "The environment variable MFLUX_PORT has not been defined.";
echo "This environment variable must be set to the port number used"
echo "for the network connection.";
echo "";
echo "The transport will be assumed as follows:";
echo "";
echo " Port Transport";
echo " ----------------------";
echo " 80 HTTP";
echo " 443 HTTPS";
echo " * TCP/IP";
echo "";
echo "That is, any other port will be assumed to be TCP/IP unless";
echo "the environment variable MFLUX_TRANSPORT is set.";
exit 1;
}
fi
if [ -z "$MFLUX_TRANSPORT" ]
then {
case "$MFLUX_PORT" in
80)
MFLUX_TRANSPORT=HTTP
;;
443)
MFLUX_TRANSPORT=HTTPS
;;
*)
MFLUX_TRANSPORT=TCPIP
;;
esac
}
fi
}
fi
if [ -z "$MFLUX_OUTPUT" ]
then {
MFLUX_OUTPUT=shell
}
fi
case "$MFLUX_OUTPUT" in
xml)
;;
shell)
;;
*)
echo "If provided, the environment variable MFLUX_OUTPUT must be";
echo "set to either 'shell' or 'xml'. Defaults to 'shell'";
exit -1;
;;
esac
}
# We use the hostname to qualify the location of the SID file
# Since a SID is only valid for a given host.
# MFLUX_SID_FILE is a file in which we will store the current
# session id for this user. The session will then be valid for
# any session for that user on this host.
MFLUX_SID_FILE=~/.MFLUX_SID_$MFLUX_HOST
# Function: logon
#
logon() {
check_env;
if test -f "$MFLUX_SID_FILE"
then {
logoff
}
fi
if [ -z $MFLUX_CFG ]
then {
MFLUX_SID=`java -Djava.net.preferIPv4Stack=true -Dmf.host=$MFLUX_HOST -Dmf.port=$MFLUX_PORT -Dmf.transport=$MFLUX_TRANSPORT -cp $MFLUX_ATERM arc.mf.command.Execute logon $1 $2 $3 $4`
} else {
MFLUX_SID=`java -Djava.net.preferIPv4Stack=true -Dmf.cfg=$MFLUX_CFG -cp $MFLUX_ATERM arc.mf.command.Execute logon`
}
fi
RETVAL=$?
case $RETVAL in
0) echo $MFLUX_SID >> "$MFLUX_SID_FILE"
;;
2) echo "Authentication failure"
;;
esac
}
# Function: help
#
# This executes displays command help
#
help() {
check_env;
if test -f "$MFLUX_SID_FILE"
then {
MFLUX_SID=`cat "$MFLUX_SID_FILE"`
if [ -z $MFLUX_CFG ]
then {
java -Djava.net.preferIPv4Stack=true -Dmf.host=$MFLUX_HOST -Dmf.port=$MFLUX_PORT -Dmf.transport=$MFLUX_TRANSPORT -Dmf.sid=$MFLUX_SID -Dmf.result=$MFLUX_OUTPUT -cp $MFLUX_ATERM arc.mf.command.Execute $*
} else {
java -Djava.net.preferIPv4Stack=true -Dmf.cfg=$MFLUX_CFG -Dmf.sid=$MFLUX_SID -Dmf.result=$MFLUX_OUTPUT -cp $MFLUX_ATERM arc.mf.command.Execute $*
}
fi
RETVAL=$?
case $RETVAL in
3) echo "Session has timed out - need to logon again.";
rm -f "$MFLUX_SID_FILE"
;;
esac
} else {
echo "Not logged on"
RETVAL=1
}
fi
}
# Function: execute
#
# This executes an arbitrary command.
#
execute() {
check_env;
#
# Account for secure token being passed through..
#
if [ "$1" == "-token" ]
then {
java -Djava.net.preferIPv4Stack=true -Dmf.host=$MFLUX_HOST -Dmf.port=$MFLUX_PORT -Dmf.transport=$MFLUX_TRANSPORT -Dmf.sid=$MFLUX_SID -Dmf.result=$MFLUX_OUTPUT -cp $MFLUX_ATERM arc.mf.command.Execute $*
RETVAL=$?
case $RETVAL in
3) echo "Session has timed out - need to logon again.";
rm -f "$MFLUX_SID_FILE"
;;
esac
} else {
#
# No token, so expect SID file
#
if test -f "$MFLUX_SID_FILE"
then {
MFLUX_SID=`cat "$MFLUX_SID_FILE"`
if [ -z $MFLUX_CFG ]
then {
java -Djava.net.preferIPv4Stack=true -Dmf.host=$MFLUX_HOST -Dmf.port=$MFLUX_PORT -Dmf.transport=$MFLUX_TRANSPORT -Dmf.sid=$MFLUX_SID -Dmf.result=$MFLUX_OUTPUT -cp $MFLUX_ATERM arc.mf.command.Execute $*
} else {
java -Djava.net.preferIPv4Stack=true -Dmf.cfg=$MFLUX_CFG -Dmf.sid=$MFLUX_SID -Dmf.result=$MFLUX_OUTPUT -cp $MFLUX_ATERM arc.mf.command.Execute $*
}
fi
RETVAL=$?
case $RETVAL in
3) echo "Session has timed out - need to logon again.";
rm -f "$MFLUX_SID_FILE"
;;
esac
} else {
echo "Not logged on"
RETVAL=1
}
fi
}
fi
}
# Function: import
#
# This executes an arbitrary command.
#
import() {
check_env;
if test -f "$MFLUX_SID_FILE"
then {
MFLUX_SID=`cat "$MFLUX_SID_FILE"`
if [ -z $MFLUX_CFG ]
then {
java -Djava.net.preferIPv4Stack=true -Dmf.host=$MFLUX_HOST -Dmf.port=$MFLUX_PORT -Dmf.transport=$MFLUX_TRANSPORT -Dmf.sid=$MFLUX_SID -Dmf.result=$MFLUX_OUTPUT -cp $MFLUX_ATERM arc.mf.command.Execute import $*
} else {
java -Djava.net.preferIPv4Stack=true -Dmf.cfg=$MFLUX_CFG -Dmf.sid=$MFLUX_SID -Dmf.result=$MFLUX_OUTPUT -cp $MFLUX_ATERM arc.mf.command.Execute import $*
}
fi
RETVAL=$?
case $RETVAL in
3) echo "Session has timed out - need to logon again.";
rm -f "$MFLUX_SID_FILE"
;;
esac
} else {
echo "Not logged on"
RETVAL=1
}
fi
}
# Function: logoff
#
logoff() {
check_env;
if test -f "$MFLUX_SID_FILE"
then {
MFLUX_SID=`cat "$MFLUX_SID_FILE"`
# Remove the file now..
rm -f "$MFLUX_SID_FILE"
java -Djava.net.preferIPv4Stack=true -Dmf.host=$MFLUX_HOST -Dmf.port=$MFLUX_PORT -Dmf.transport=$MFLUX_TRANSPORT -Dmf.sid=$MFLUX_SID -cp $MFLUX_ATERM arc.mf.command.Execute logoff
RETVAL=$?
} else {
echo "Not logged on"
RETVAL=1
}
fi
}
# Function: status
#
status() {
if test -f "$MFLUX_SID_FILE"
then {
MFLUX_SID=`cat "$MFLUX_SID_FILE"`
echo "Logged on in session $MFLUX_SID"
} else {
echo "Not logged on"
}
fi
RETVAL=1
}
# Options:
#
case "$1" in
logon)
logon $2 $3 $4 $5
;;
logoff)
logoff
;;
import)
import $2 $3 $4 $5 $6 $7 $8
;;
status)
status
;;
help)
help $*
;;
--help)
echo $"Usage: $0 {logon|logoff|status|help|<mediaflux service>}"
RETVAL=1
;;
*)
execute $*
;;
esac
exit $RETVAL
Examples
Log on using user password
Log on
Execute the mediaflux command server.uuid
Print the result
Log off
#!/bin/bash
MFLUX_SID=`java -cp /path/to/aterm.jar -Dmf.cfg=$MFLUX_CFG arc.mf.command.Execute logon YourDomain YourUsername YourPassword`
MFLUX_UUID=`java -cp /path/to/aterm.jar -Dmf.cfg=$MFLUX_CFG -Dmf.sid=$MFLUX_SID -Dmf.result=shell arc.mf.command.Execute server.uuid`
echo $MFLUX_UUID
java -cp /path/to/aterm.jar -Dmf.cfg=$MFLUX_CFG -Dmf.sid=$MFLUX_SID arc.mf.command.Execute logoff |
Log on using token with app restriction
Log on
Execute the mediaflux command server.uuid
Print the result
Log off
#!/bin/bash
MFLUX_SID=`java -cp /path/to/aterm.jar -Dmf.cfg=$MFLUX_CFG arc.mf.command.Execute logon -token $TOKEN -app $APP`
MFLUX_UUID=`java -cp /path/to/aterm.jar -Dmf.cfg=$MFLUX_CFG -Dmf.sid=$MFLUX_SID -Dmf.result=shell arc.mf.command.Execute server.uuid`
echo $MFLUX_UUID
java -cp /path/to/aterm.jar -Dmf.cfg=$MFLUX_CFG -Dmf.sid=$MFLUX_SID arc.mf.command.Execute logoff |