Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing SPSL the SuperPuTTY Scripting Language #558

Open
jimradford opened this issue Oct 16, 2015 · 17 comments
Open

Introducing SPSL the SuperPuTTY Scripting Language #558

jimradford opened this issue Oct 16, 2015 · 17 comments

Comments

@jimradford
Copy link
Owner

I've worked up a working prototype of a very basic scripting language for use in the script sender from the toolbar to aid in automation tasks.

I use the term "language" loosely since what it actually currently does is modify the behavior of the commands being sent. It is still very infant in its design and concept and I want more feedback to know what kinds of things users would like to see.

Execution Behavior
Lines are read from a text based script and executed in order they appear. The script runs in a single thread to prevent the application from becoming unresponsive when sleep or commands that would block the main application thread are encountered. It runs until its done. There are no loops or comparative operators currently implemented. When the last line is ran the script execution finishes.

Commands
These are predefined functions with arguments that can be passed. For example SENDCHAR t when encountered would send the single character t to selected sessions.

Replaceable Variables
Variables when wrapped in a specific format can be replaced at run time to dynamically change the information being sent to a terminal. For example <%Var(Session.Name)%> would be replaced with the name of the session the data is being sent to. For example SENDLINE echo <%Var(Session.Name)%> might send the command "echo router1.core-fe0-1.foo.com" to the terminal and be specific to the session where the command is being sent.

Running a script when a session is launched
It only makes sense to be able to associate a script file with a session and automatically run the script when the session is launched.

See the Wiki for the language reference and examples

Please note everything could change before this functionality is included in a release and supported as such and appropriately documented. I want the language to be robust and not conflicting with existing functionality and workflows. Consider this an Alpha developer feature.

@jimradford jimradford added this to the v1.4.0.8 milestone Oct 16, 2015
@jimradford jimradford changed the title Introducing the SPSL (SuperPuTTY Scripting Language) Introducing SPSL the SuperPuTTY Scripting Language Oct 16, 2015
jimradford added a commit that referenced this issue Oct 22, 2015
…nched, or restored from auto layout

* Better handling when a new session process is unable to start due to command line arguments or other reasons causing process to not start. should fix unhandled exception in Issue #528
@jimradford
Copy link
Owner Author

One thing to note from commit 0b35374 When executing scripts during the start of a session, if for example you are using the OPENSESSION script command to open the same session it WILL create an endless loop, first time I did it with a test script it made me laugh when I realized what I did. I am not sure if I should add logic to prevent such things from happening since the application is actually doing exactly what it was told to do.

@Zenrage
Copy link

Zenrage commented Jan 4, 2016

Just wanted to leave a note that this feature set as it currently stands is very very useful for my job. Aside from the SENDKEY {SPACE} not working well, this would make programming our equipment via serial connection very quick.

I can rig a script based off of our Frequencies and other parameters for technicians out in the field. If the Spacebar (for the two option selection) would work this would be a great replacement (as everyone uses Putty)

I was able to do a spacebar by using SENDLINE " "

@vvolsen
Copy link

vvolsen commented Mar 7, 2016

More or less exactly what I need, but currently it's executing script the moment I open a session. Workaround for me is to start script with SLEEP, but as how long login takes varies between sites this is not very reliable. Would it be possible to add an option to wait until login complete or some kind of expect behavior?

@mcarbonneaux
Copy link

while be intersting to add readline with read windows box for reading the line.
and reuse this as variable in sendline.

with that they are not oblige to store password in spsl script...

@xtipacko
Copy link

How to use it with any session by default?

@ghost
Copy link

ghost commented Oct 27, 2016

great idea.
I'm sad that SENDKEY {ENTER} does not work for me.
SENDLINE does not either because the carriage return is not sent.
I'm trying to use spsl script in a minTTY local session because I want some environment variables to be set when start the terminal. Maybe there's a better way than using spsl but I can't figure it out.

@kczx3
Copy link

kczx3 commented Aug 11, 2017

It would be awesome if there were a quicker way of executing a script. I'd like to be able to set a config option as to the directory where all my scripts are and they can be loaded on opening of SuperPutty into a toolbar or something so all I have to do is click a button to execute the script instead of having to load it each time by finding the file.

@rel1sh
Copy link

rel1sh commented Nov 22, 2017

+1 to @DaLouuu's comment about spsl not sending the CR with SENDLINE or explicitly with SENDKEY {ENTER} - not sure if this is an incompatibility with MinTTY or something else, because the full text of the SENDLINE command is sent and sits there waiting on the terminal input for me to hit the Enter key.

@overproof876
Copy link

overproof876 commented Feb 15, 2018

Thanks for this, I've been able to use this to save a couple keystrokes while creating a local user on Cisco devices.

#!/bin/spsl
SENDLINE #INSERT USERNAME#
SLEEP 1000
SENDLINE #PASSWORD#
SLEEP 1000
SENDLINE config t
SENDLINE username #USERNAME# privilege 15 secret 5 #INSERT MD5 HASH#
SLEEP 1000
SENDLINE do show run | inc user

If anyone can suggest a way for me to verify if the username was successfully added based on the output of the show command that would be appreciated. Ideally I would like to save config then exit the session if successful or leave the session open if unsuccessful. That part is easy enough with SPSL but the verification part is where i'm stumped.

@nimrod1313
Copy link

Hi:
I've to about 20 scripts that I use on a regular basis. In a busy day I may run each script several times, so running a script about 30 time/day. Now the problem I have is that running each script involves 5 steps:

  1. Click Script Editor Icon
  2. Click Load Command button
  3. In browser navigate to scripts
  4. Dbl Click on Script
    5 Click Send Button.

This just seems like a lot of steps to run a script. My Suggestion would be to have a visible scrolling list , kind of like that "Sesstions" list . But instead of sessions it would be a scrolling list of all the scripts in a specified directory.
So then when I want to run a script I just dbl click on it in the scrollable list. So I go from 5 steps to run a script to a simple single step of a dbl click. This would change my daily process from 150 clicks to just 30.

Thanks

@jimradford
Copy link
Owner Author

jimradford commented Apr 13, 2018 via email

@TrippyHippyDan
Copy link

I use this often and the scripts are amazing. Question on this and I feel its asking too much, but better to be asked then not asked.

Would there be any possible way to get an expect type behavior where if X is not the next line response it kills the script?

@quan3t
Copy link

quan3t commented Oct 11, 2018

how do I send a SHIFT+Insert combo? I tried SENDKEY +{INS} but not working.

@richardsonj
Copy link

The ability to add multiple scripts that run consecutively would be nice. Alternatively, if you could invoke a script from inside another script, that would work.

Often times, I'm logging onto a server to access one of a few specific applications, It would be nice to be able to have one login script, and then a set of scripts for logging into those applications. That way, if my password changes, I only have to change the login script.

@moonshotkilla
Copy link

Hey, I really need the <%Var(Session.HostName)%> feature to work. It would make automating my database backups possible. Will this ever be activated?

@VictorGarcia9
Copy link

¿How can i use "OPENSESSION"? it's like:
OPENSESSION 0.0.0.0
¿or maybe it's OPENSESSESION EXAMPLE?

@jimradford
Copy link
Owner Author

jimradford commented Jun 23, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests