From 6e0141514e49ae9cde362f16a1af2b15881ec76a Mon Sep 17 00:00:00 2001 From: Hsin Yuan Yeh Date: Sun, 22 Oct 2023 14:38:39 +0800 Subject: [PATCH] updating gh-pages repo --- v2/gettingstarted.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/v2/gettingstarted.md b/v2/gettingstarted.md index 43b7d2e..a6a6fc5 100644 --- a/v2/gettingstarted.md +++ b/v2/gettingstarted.md @@ -43,4 +43,47 @@ Once you have the path to the SSHScript CLI, you can add it to your PATH environ export PATH=$PATH:/path/to/sshscript ``` +## 🔵 Checking if SSHScript works + +SSHScript works in two ways: SSHScript dollar-syntax and python module. + +### SSHScript dollar-syntax + +SSHScript adds additional syntax that could used in regular python statements. +Because those additional syntax are started with $(dollar), so it is called dollar-syntax. + +A python script with dollar-syntax is excuted by the SSHScript CLI "sshscript" command. + +For example: +``` +$hostname +print($.stdout.strip()) +``` +This two-lines example would execute command "hostname" and print the output on stdout. +To run it, please save it as "example.spy", then in the console, runs: +``` +sshscript example.spy +``` + +### SSHScript module + +SSHScript v2.0 has refined the functionality of module for users who can use sshscript without written syntax-dollar. +It is also easier to use SSHScript module when integrating with existing projects. + +For example: +``` +import sshscript +session = sshscript.SSHScriptSession() +session(hostname) +print(session.stdout.strip()) +``` +This example would execute command "hostname" and print the output on stdout, too. +To run it, please save it as "example.py", then in the console, runs: +``` +python3 example.py +``` + +### The difference between SSHScript dollar-syntax and module + + Once you have added the path to your PATH environment variable, you should be able to run the sshscript command from anywhere in your terminal.