Skip to content

Releases: iapyeh/sshscript

v2.0.2 Latest Version

29 Dec 07:37
80b0706
Compare
Choose a tag to compare

SSHScript v2.0.2 Release Notes

Last Updated on 2023/10/21

Summary

SSHScript v2.0.2 reimplements its dollar-syntax functionality using the Python.ast module, making it more flexible and consistent.
Threading support has also been reimplemented, and SSHScript v2.0.2 now supports connecting to multiple hosts at the same time.

You can also now use all SSHScript functions in a regular Python script without needing to use dollar-syntax.
This makes your scripts easier to integrate with existing scripts.

Improvements

  • Reimplemented syntax parsing: More flexible and consistent dollar-syntax functionality.
  • Reimplemented threading support: SSHScript v2.0.2 now supports connecting to multiple hosts at the same time. This can improve the performance of your scripts, especially when you need to execute commands on multiple hosts simultaneously.
  • Improved robustness and stability: SSHScript v2.0.2 has greatly refined the way it interacts with the shell console to improve its robustness and stability. This makes your scripts less likely to fail or crash.
  • Handy functions for regular tasks: SSHScript v2.0.2 provides handy functions for regular tasks, such as sudo and su. This makes it easier to write scripts that perform these tasks.
  • Better handling of foreground processes: SSHScript v2.0.2 now handles foreground processes, such as tcpdump, better. This makes it easier to write scripts that use these types of processes.

Overall, SSHScript v2.0.2 is a significant improvement over previous versions. It is more flexible, consistent, robust, and stable. It is also easier to use, thanks to the new handy functions and improved foreground process handling.

New Features

  • $.sudo(password), get a root console: The $.sudo function returns a console as the root user. This can be useful for executing commands that require root privileges. Details

  • $.su(username,password), get a different user console: The $.su() function returns a console as the specified user. This can be useful for executing commands as a different user, such as sudoer account. Details

  • $.enter(command), get an interactive console: The $.enter() function returns a console of an interactive process. This can be useful for executing interactive tools, such as mysql-client. Details

  • $.iterate(command), iterate over foreground command outputs: The $.iterate() function returns a loopable console for iterating over the output of a foreground command, such astcpdump`. This can be useful for processing the output of foreground commands in real time. Details

  • $.thread(target), create a new SSHScript-aware thread: The $.thread() function creates a new thread that takes the session as its effective sessions. This can be useful for executing commands in a multithreaded environment. Details

Changes

  • $.log() is removed, please use $.logger instead. The reason for this is that $.logger is more easier. For example
## In SSHScript v1.0
import logging
$.log(logging.DEBUG, 'message')
## In SSHScript v2.0, use the built-in logging functionality (no need to import the logging module or type as much).
$.logger.debug('message')

Additional Notes

  • $@{var} is going to be deprecated in next release of v2.0. Please use f-string instead. For example:
cmd="hello world"
## @{cmd} is replaced with "hello world" before execution.
## the following format is going to be deprecated
$echo @{cmd}
## please use f-string instead
$f'echo {cmd}'

Simplifications in the Roadmap of SSHScript v2.0

SSHScript v2.0 will focus on improving its simplicity. The following items are on the schedule and will be implemented in next releases:

  • The usage case of with-dollar is now limited to invoking shell only. This means that with-dollar can no longer be used to execute commands. This is a simplification because it makes the with-dollar syntax more consistent and easier to understand.

    For example:

    ## would be invalid in the future
    with $"""
        #!/bin/bash
        cd $HOME
        """ as console:
            console('ls -l | grep ^d')
    
    ## valid in the future (this style is easier to understand)
    with $#!/bin/bash as console:
        console('cd $HOME')
        console('ls -l | grep ^d')
    
  • The syntax @{var} will be removed from dollar-syntax, using $f-string is recommanded. This means that you should use Python f-strings instead of @{var} to insert variables into dollar-syntax commands. This is a simplification because f-strings are more concise and easier to use.

    For example:

    greeting = 'hello world'
    ## would be invalid in the future
    $echo @{greeting}
    ## using f-string is encouraged
    $f'echo {greeting}`
    

SSHScript v2.0 is still under development. If you find any bugs or have any suggestions, you are welcome to post them on the issues page.

Last updated on 2023-10-21

0.94

01 Jun 09:13
Compare
Choose a tag to compare
0.94 Pre-release
Pre-release

0.94