Scripting the TerraBlock CommandApp

Facilis Technology, Inc. Technical Note
TN-044
Scripting the TerraBlock CommandApp
The addition of the CommandApp to the TerraBlock Manager allows for the scripting and
automation of some Terrablock Manager commands. The application allows for certain variables
to be set when running.
CommandApp.exe -i ipaddr -u username -p password -command
-i – Specify the IP address of the TerraBlock server if connecting via Ethernet.
-u – Specify the username you wish to log into the Terrablock server with.
-p – Specify the password if username and password login is enabled on the Terrablock server.
Enter “” for no password.
Commands
-l
- list volumes
-f
- list users
-s
- list system
-r
- remount multiwrite volumes
-m
- mount volume
-mr
- mount read only
-e
- unmount volume
Note: To learn more about running the CommandApp consult chapter 9 of the Users Guide.
Though all of the above commands are scriptable, remount multiwrite volumes is the most
desired to automate. Below are examples for Windows, Mac and Linux on how to create scripts
and automate the remount multiwrite volumes command.
Windows
Start by opening a new Notepad document. In the document enter the following text.
ping 127.0.0.1 -n 6 >null
cd \Program Files\Windows Manager\Command App
start /B TerraBlockManager.exe -i <ipaddress> -u <username> -p <password> –r
Save the file and rename the extension to .bat.
Explanation:
ping 127.0.0.1 -n 6 >null This line ping the loopback IP address to create about a 5 second delay
in the script at startup. There needs to be a delay for the Multi Volumes.
cd \Program Files\Windows Manager\Command App This line changes the directory to the
windows manager Command App directory in Program Files. This would need to match
Technical Note
1 of 5
2/1/2016
wherever you have the Manager installed. For instance if the folder were on the desktop on a
Windows 7 machine the line would read “cd \users\<username>\Desktop\Windows
Manager\Command App”
start CommandApp.exe -i <ipaddress> -u <username> -p <password> –r This line starts the
CommandApp in the same window. –i specifies the ip address of the TerraBlock server. –u
specifies the username you wish to log into the TerraBlock with. –p Specifies the users password
if user and password is enabled on the server (use “” for no password). –r remounts MultiWrite
volumes.
To launch the script at startup place it in:
C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
This script will launch a CMD window. To hide the CMD window you will need to create a second
script.
In another notepad document enter the following:
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & “C:\Program Files\Windows Manager\Delay_Command_App_Launch.bat" & Chr(34), 0
Set WshShell = Nothing
The path and file name is the location of the original script. This example assumes you put the
script in the Windows Manager folder and named the script Delay_Command_App_Launch.bat.
Save this file and rename the extension to .vbs.
You can then place the .vbs file in the startup programs.
Note: Windows 8 and higher may require that the App be set to run as an administrator.
Mac
Start by opening a new TextEdit document. In the document enter the following text.
#!/bin/sh
sleep 5
cd /Applications/Mac\ Manager
./CommandApp -i <ipaddress> -u <username> -p <password> –r
Save the file and change the extension to .sh.
Explanation:
#!/bin/sh Executes the file using sh.
Sleep 5 Adds a 5 second delay to the script.
cd /Applications/Mac\ Manager Changes the directory to the Mac Manager folder.
./CommandApp -i <ipaddress> -u <username> -p <password> –r This line starts the
CommandApp. –i specifies the ip address of the TerraBlock server. –u specifies the username
you wish to log into the TerraBlock with. –p Specifies the users password if user and password is
enabled on the server (use “” for no password). –r remounts MultiWrite volumes.
Once saved with the .sh extension we need to make the file executable. Launch the Terminal
from /Applications/ Utilities. Type chmod +x then drag the .sh file into terminal and hit enter. This
will make the script executable.
Technical Note
2 of 5
2/1/2016
This script will run in a Terminal window. To make the script run in the background we will need
to wrap it as an application in Automator.
In /Applications launch Automator. Once Automator launches create a new Application then add
a run shell script task by double clicking it in Actions> Utilities. You can then drag the script into
the task. See image below.
Technical Note
3 of 5
2/1/2016
Choose File> Save and save with the file format of Application.
The application can now be added to the users startup items in order to run at startup.
Linux
Technical Note
4 of 5
2/1/2016
In linux you can create the same shell script with a text editor (or copy over a script from a mac).
You would need to change the location of the manager to the file path of the Linux_Manager.
You will also need to make the file executable using chmod +x before it can be run.
On CentOS the script can be named “default” and placed in /etc/gdm/PostLogin/ to run at login
automatically. If there is already a default script to run in this location the lines of the script can
be added or lines to run the script in a different location.
If the script does not run after making it executable you may need to make it in bash instead of
sh. To do this begin the first line of your script with #!/bin/bash instead of #!/bin/sh.
Technical Note
5 of 5
2/1/2016