Skip to content

Instantly share code, notes, and snippets.

@benwei
Last active March 14, 2019 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benwei/70b0f532adaa75aef1be3dec7abfc975 to your computer and use it in GitHub Desktop.
Save benwei/70b0f532adaa75aef1be3dec7abfc975 to your computer and use it in GitHub Desktop.
run remote cases by ssh with multiple arguments using shell - https://ben6.blogspot.com/2019/03/run-command-with-multiple-arguments.html
#/bin/bash
# 2019 Ben Wei <ben@juluos.org>
#
# This is a example script for CI tests for blog
# if not defined in environment variable
# you can use the following command to defined it
#
# export TEST_SSH_HOST="your_ssh_host"
#
function run_cases()
{
local case_name="$1"
local args=""
while [ ! "x$1" = "x" ]; do
printf -v __ %q "$1"
args="$args \"$__\""
shift
done
if [ "x${TEST_SSH_HOST}" = "x" ]; then
TEST_SSH_HOST=test-server
fi
ssh ${TEST_SSH_HOST} "cd test-cases; /bin/bash ./tests.sh $args"
return $?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment