API scripts: Get more from your EFT Server
By Sally Gates | Dec 6, 2018 | EFT, News, Top Tips
API calls can also be used to get information out of the system. Some examples include:
- The number of Workspaces licences in use by a specific group of users.
- A list of all users, when they logged in and even if their password has expired.
All this information is available through the console app but cannot be compiled in a simple list.
Getting started with scripts
Before you can start to use the API script you will need the COM API installed onto the machine where the script will be executed.
Finally, you will need to enable COM access for an Admin user (managed through the EFT console via the Administration tab of the server).
Although the syntax of commands may alter between scripting languages, every script needs to declare connection information via a COM object. For example, a typical opening section of a VB Script may include the following lines:
CRLF = (Chr(13)& Chr(10))
txtPort = “1111”
txtAdminUserName = “API”
txtPassword = “A1bC3d$E5”
<- Put your Admin port here
<- This is the user name
<- This is the user password
Set objFSO=CreateObject(“Scripting.FileSystemObject”)
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write “There are a maximum of ” & SFTPServer.WSSeatsMax & ” seats available.” & vbCrLf
objFile.Write “There are ” & SFTPServer.WSSeatsUsed & ” seats in use” & vbCrLf
objFile.Write “That leaves ” & Seatsleft & ” seats unused” & vbCrLf
objFile.Close
This will output a string to a file which would look similar to this.
There are a maximum of 25 seats available
There are 8 seats in use
That leaves 17 seats unused
Automating the script
Our definition of the cScript command in our EFT looks like this and allows a filename to be passed to the script as well.
In our Event rule, the output file is emailed to a user as an attachment.
Need help or short of time?
More information
- A full list of all functions and API commands is available online at https://help.globalscape.com/help/gs_com_api/
- Sample scripts are available to download at https://help.globalscape.com/help/gs_com_api/#t=COM_Script_Examples.htm
- Help with creating custom commands can be found at https://help.globalscape.com/help/eft7-4/#t=mergedProjects%2Fcommands%2FCustom_Commands.htm