Setting aliases

This page will explain how you can set a shorthand command to connect to Holodeck.

Attached to this article you will find a bash script that will automatically set three aliases (and is easily modifiable to add more and custom ones), though there is no guarantee that it will work or keep your system intact. So use it at your own risk.

Setting aliases manually

To set an alias we will use the command
alias <shortcut_name>="<command_to_execute>"

To be able to just type the shortcut name from anywhere on the system you need to add it to a file called
~/.bash_aliases

If this file does not exist, create it using
touch ~/.bash_aliases

and edit it afterwards using a text editor of your choice. If you are using Ubuntu gedit should be installed by default (if you are not on Ubuntu, choose a different text editor or install gedit), so type
gedit ~/.bash_aliases

to get the file in the text editor. Insert the aliases you want into this file, save and exit. An example of a ~/.bash_aliases file is
alias grid="grid-proxy-init"

alias holodeck1="gsissh holodeck1.aei.uni-hannover.de"

alias holodeck2="gsissh holodeck2.aei.uni-hannover.de"

which defines the shortcuts “grid” to initiate a grid-proxy, “holodeck1” to connect to holodeck1 and “holodeck2” to connect to holodeck2. (This is the default aliases the provided script will set.)

In order to be able to use these commands we also need to take a look into the ~/.bashrc file. Again type
gedit ~/.bashrc

In this file look for the lines
if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

If you can’t find them copy them into the file, save and exit.

The last step you have to do is run
source ~/.bashrc

Now the shortcuts should be defined.

Note that you have to source the ~/.bashrc file every time you change you ~/bash_aliases file.

Setting aliases using the script

The bash script simply executes the steps described in the section about adding aliases manually. The paths it is looking at are hard-coded. The same is true for the structure the script is looking for in the ~/.bashrc file.

Running the script

To run the script simply download it, open the directory, it is located in, in a terminal and type
bash set_aliases.sh

The script will (by default) create three aliases: “grid”, “holodeck1” and “holodeck2”. The first one is equivalent to
grid-proxy-init

the other two connect you to Holodeck and are equivalent to
gsissh holodeck<x>.aei.uni-hannover.de

where <x> is the number of the Holodeck head node.

Setting more / different aliases and names using the script

To add more aliases and/or change the name/behavior of existing aliases you simply have to edit the script. The third line begins with “parts=” and a few commands within round brackets. To add a new command simply enclose it in double-quotes and replace any double-quotes in the command you are trying to make an alias for by \".

Example:

We write an alias to connect to connect to Atlas head node 5. The command in its pure form would be:
alias atlas5="gsissh atlas5.atlas.aei.uni-hannover.de"

To add this to the script we would append
"alias atlas5=\"atlas5.atlas.aei.uni-hannover.de\""

to the array called “parts”. To add it to the array we copy this modified string to the last position of the array and make sure that the previous contents and this new string are separated by a space. Therefore the new array “parts” would be:
parts=("alias grid=\"grid-proxy-init\"" "alias holodeck1=\"gsissh holodeck1.aei.uni-hannover.de\"" "alias holodeck2=\"gsissh holodeck2.aei.uni-hannover.de\"" "alias atlas5=\"gsissh atlas5.atlas.aei.uni-hannover.de\"")

Save the script and run it.

See also

Useful commands · Quick start guide

-- MarlinSchFer - 08 May 2019

This topic: NumRel > WebHome > HoloDeck > HoloQuickStartGuide > HoloAliases
Topic revision: 08 May 2019, MarlinSchFer
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback