Skip to content

Commit

Permalink
updating gh-pages repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Hsin Yuan Yeh authored and Hsin Yuan Yeh committed Oct 22, 2023
1 parent 2514a0e commit 6e01415
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions v2/gettingstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

## 🔵 <a name="check-works"></a> 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.

0 comments on commit 6e01415

Please sign in to comment.