Create two scripts.
automation.sh:
#!/usr/bin/env bash set -x SCRIPT_DIR=$(dirname "$0") || exit 1 HOST=$1 echo $HOST ssh vyos@10.0.0.1 '/bin/vbash -s' < "${SCRIPT_DIR}/some_script.sh" "${HOST}"
some_script.sh:
#!/bin/vbash source /opt/vyatta/etc/functions/script-template HOSTNAME="$1" # Load VyOS environment echo $HOSTNAME
Now, with both scripts in the local directory, run
./automation.sh test
Observe on the local side, "test" is printed.
On the remote side, "1" is printed. "test" is expected.
This worked with 1.3.
$ show version Version: VyOS 1.5-rolling-202401260023 Release train: current Built by: autobuild@vyos.net Built on: Fri 26 Jan 2024 02:16 UTC Build UUID: a910324d-c275-44d3-b026-bde38781fd97 Build commit ID: 6c6a5856122790 Architecture: x86_64 Boot via: installed image System type: bare metal Hardware vendor: HP Hardware model: HP EliteDesk 800 G5 Desktop Mini Hardware S/N: MXL95025NY Hardware UUID: 800b5dc3-e6c8-ba65-0bcb-dc6bfdfbccb2 Copyright: VyOS maintainers and contributors