Skip to content

SPSL Reference (SuperPuTTY Scripting Language)

puni999 edited this page Nov 13, 2022 · 6 revisions

Introduction

SPSL (SuperPuTTY Scripting Language) is an experimental feature being developed for the SuperPuTTY application to allow scripted automation of tasks. Currently the focus is on sending commands to open terminal sessions with the ability to change the timing of the execution and dynamically replace variables with session specific data. In the future it could also include functionality to allow managing the GUI and performing tasks related to the SuperPuTTY application itself. At this point it should be considered an alpha developer feature.

We are currently in the planning stages of this feature although some basic functionality has been implemented as a proof of concept and to gather feedback from users who might find this feature useful.

Feedback

Any input and feedback should be discussed in issue #558 in the issue tracker https://github.com/jimradford/superputty/issues/558

Script Format

All spsl scripts must begin with the line: #!/bin/spsl. When this line is encountered the parser engine is started and the script is executed. Otherwise the lines in the script are sent line by line to the terminal sessions without buffering or any modification.

Lines beginning with a # are treated as comments and ignored and not sent to terminal sessions.

Command Reference

Commands start with a keyword and are followed by a space and any arguments appropriate and required for the command. Commands are not case specific but converted


CLOSESESSION
Description: Close an existing session
Status: **Not Implemented**
Parameters: Session Name
Example: CLOSESESSION foo.bar.com

OPENSESSION
Description: Launch/Open a new session
Status: Implemented
Parameters: Session Name
Example: OPENSESSION SessionID

SENDCHAR
Description: Send a single character to terminal sessions
Status: Implemented
Parameters: Char(1)
Example: SENDCHAR 1

SENDLINE
Description: Send a line followed by a carriage return to terminal sessions
Status: Implemented
Parameters: String
Example: SENDLINE whoami

SENDKEY
Description: Send keystrokes to terminal sessions
Status: Implemented
Parameters: Keystrokes encapsulated in squirly braces
Example: SENDKEY {ENTER}
Example: SENDKEY ^L ** A known issue exists sending keystrokes with special keys

See: SendKey Keylist

See: https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send%28v=vs.110%29.aspx


SLEEP
Description: Delay execution of next script line for the specified number of milliseconds. 1000ms = 1 sec
Status: Implemented
Parameters: Int
Example: SLEEP 1000

PROMPT
Description: Request input from user
Status: Implemented
Parameters: String The text to be displayed in the dialog box 
Example: PROMPT What is your password?
Added: v1.4.0.11

Variable Reference

Variables are encapsulated starting with <%VAR( and ending with )%> and are replaced at script execution time with the data specific to the variable keyword encapsulated. Variable encapsulation and names are not case sensitive.

Note The encapsulation characters and format will be changeable at run-time to minimize conflicts with commands being sent. The default prefix is <%VAR(. The default suffix is )%>.

Session Specific Variables:


Session.Name
Description: Expands to the name of the session
Status: **Not Implemented**
Example: <%VAR(Session.Name)%>

Session.Hostname
Description: Expands to the Name or IP of the session host from the Host Name field
Status: **Not Implemented**
Example: <%VAR(Session.Hostname)%>

Session.Port
Description: Expands to the port number of the session host from the port field
Status: **Not Implemented**
Example: <%VAR(Session.Port)%>

Session.Proto
Description: Expands to the protocol of the session host from the Protocol field
Status: **Not Implemented**
Example: <%VAR(Session.Protocol)%>

Examples

#!/bin/spsl
SENDLINE clear
SENDCHAR l
SLEEP 500
SENDCHAR s
SENDKEY {ENTER}
SENDLINE echo This terminal session is connected to <%VAR(Session.Hostname)%>

Would result in (assuming your session host name is foo.bar.com):

jradford@foo:~> ls
folder with space  octmp
jradford@foo:~> echo this terminal session is connected to foo.bar.com
this terminal session is connected to foo.bar.com
jradford@foo:~>

Typical usage:

#!/bin/spsl
SENDLINE sudo -i
SENDLINE mc
SENDLINE ./do-some-stuf.sh