# bash-xops

> A library for executing bash ops through ssh with expect prior to node.js installation on remotes

Latest version **1.0.1** (published 2023-07-03) · GPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install bash-xops
pnpm add bash-xops
yarn add bash-xops
bun add bash-xops
```

Provides the command `xops`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-07-03 |
| First published | 2023-07-03 |
| Weekly downloads | 0 |
| License | GPL-3.0-or-later |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 1.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | R. Leddy |
| Maintainers | rleddy |
| Keywords | bash, ssh, scp, help, install, node |

## Links

- npm: https://www.npmjs.com/package/bash-xops
- Repository: https://github.com/copious-world/bash-xops
- Homepage: https://github.com/copious-world/bash-xops#readme
- Issues: https://github.com/copious-world/bash-xops/issues
- Funding: https://github.com/sponsors/copious-world
- npm.io page: https://npm.io/package/bash-xops

## Dependencies (2)

- [gift-cli](https://npm.io/package/gift-cli.md) ^1.0.4
- [extra-file-class](https://npm.io/package/extra-file-class.md) ^0.9.19

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2023-07-03

## README

# bash-xops

A library for executing `bash` ops through `ssh` with `expect` prior to node.js installation on remotes.

## rational

Since, node.js will likely not be installed on a new machine instance in some cloud, or personal cloud, it helps to have some bash commands that call upon **expect** to run remote scripts requiring entering user names and passwords. 

The methods need to send scripts to the remote computers to run, but under the authorization of ssh. The scripts can do things like install node.js, npm, n, git, etc. Once the system is ready to be used, other services can take over more with sophisticated methods for relaying assets.

The user will likely use node.js from his own computer. So, this package wraps the bash scripts so that they can be called out of node.js tools the user might create or use.

### What about Docker and others?

One might use these tools to communicate with a new instance spun up under Docker or others. 


## install

```
npm install bash-xops
```

### tiny command line tool


```
npm install -g bash-xops
```

For example:

Here is a use of the command line that has a machine configuration passed on the command line. Here, `machine.conf` has the authorization and IP information for a remote host.

First, it list a remote directory.
Second, it runs a silly script.
Third, it sends a directory up and into the test dir, *`big_test_thing`*
Fourt, it lists what's in the new remote directory.

(Note: lines ending in 'yes' are telling expect that the fingerprint will not be requested on the machine. 'yes' means we know the machine. If 'yes' is omitted, the scripts will attempt to respond to fingerprinting.)

```
$xops machine.conf
xops  test/host.conf
looking for a conf file in test/host.conf
CONFIG FILE:  test/host.conf
$>ldr . yes
$> spawn bash -c ssh moi@that-machine.what 'find  . -type d -maxdepth 1'
moi@that-machine.what password: 
.
./.forever

...

./big_test_thing
./node_modules
$>xbash test/moveme_move.sh yes test dog
$> spawn ./assets/ssh-wrapper.sh moi@that-machine.what test/moveme_move.sh "test dog"
SSH-WRAPPER moi@that-machine.what /the/cwd "test dog"
-rw-r--r--@ 1 moi  staff  63 Jul  2 18:17 test/moveme_move.sh
+ ssh moi@that-machine.what 'bash -s' '"test' 'dog"'
moi@that-machine.what's password: 
Sun 02 Jul 2023 06:38:27 PM PDT
/home/moi
It's great that dog is test
+ set +x
done-moi@that-machine.what

$> xsenddr test/moveme ./big_test_thing yes
$> spawn scp -r ./test/moveme moi@that-machine.what:./big_test_thing
moi@that-machine.what's password: 
test4.txt                                                                                                                                100%   64     2.0KB/s   00:00     
test3.txt                                                                                                                                100%   62     2.1KB/s   00:00    

$> ls big_test_thing/moveme yes
$> spawn bash -c ssh moi@that-machine.what 'ls -l big_test_thing/moveme'
moi@that-machine.what's password: 
total 8
-rw-r--r-- 1 moi moi 62 Jul  2 18:10 test3.txt
-rw-r--r-- 1 moi moi 64 Jul  2 18:10 test4.txt


```


## exported methods

* `expect_ensure_dir`
* `expect_list_dir`
* `expect_list_dir_dirs`
* `send_up`
* `expect_send_up`
* `expect_send_down`
* `send_dir_up`
* `expect_send_dir_up`
* `send_dir_down`
* `expect_send_dir_down`
* `perform_op`
* `perform_expect_op`
* `run_local_bash_script `


### All exported methods are async

All the methods are asynchronous. They should be called with await or other promise control.

Here is an example:

```
const xops = require('bash-xops')
const cmd_line_args = require('args-getter')

let [pass,user,addr,resident_file,remote_dir] = cmd_line_args()

async fun() {
	await xops.expect_send_up(pass,user,addr,resident_file,remote_dir)
}

fun()

```


### Methods starting with *expect* launch expect scripts

These scripts require passwords passed in as base64 encoded. They need the `user` and the `ip` for `ssh` as such:

```
ssh user@ip ...etc
```

The other methods will stop and ask for a password from the user.

Please refer to the docs in the *docs* directory.

---
_Source: https://npm.io/package/bash-xops · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
