小编Bra*_*don的帖子

如何强制 ssh 在远程系统而不是本地执行命令

我让 SSH 在脚本中执行一些命令,如下所示:

#!/bin/bash

REMOTEUSER=$1
REMOTEHOST=$2    
newVh=$3

ssh "$REMOTEUSER"@"$REMOTEHOST" << EOF

cd

if [ ! -d "/data/web/someDirectory" ]
then
  echo -e "There is no vhost setup for someDirectory"
  exit 1
fi


if [ ! -d "git" ]
then
  echo -e "Home git directory not found. Creating it now."
  mkdir git
fi

if [ ! -d "git/$newVh.git" ]
then
  echo -e "Bare git repository not found for $new. Creating it now."
  mkdir git/"$newVh".git
  git init --bare git/"$newVh".git
fi


EOF
Run Code Online (Sandbox Code Playgroud)

哪个工作正常并且做我想要的。我正在尝试检查compass …

bash ssh shell-script

4
推荐指数
1
解决办法
1536
查看次数

标签 统计

bash ×1

shell-script ×1

ssh ×1