Last active
August 22, 2018 06:30
-
-
Save allysonsouza/6cf842f64e8f772c89f5c589ad53df3c to your computer and use it in GitHub Desktop.
Connect to your server trough ssh and run wp-cli commands in an automated way in Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Name: db-update.bat | |
:: Purpose: Connect to server trough ssh and run wp-cli commands | |
:: Author: @allysonsouza | |
:: URL: https://github.com/allysonsouza | |
:: Version: 0.0.1 | |
:: License: GPL-v2 | |
@ECHO OFF | |
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION | |
:: variables | |
SET hostname=hostname.com.br | |
SET user=username | |
:: commands | |
SET command1=cd mydir/subdir | |
SET command2=wp config create --dbname=wpdb --dbuser=wpdbuser --dbpass=MyPass --dbhost=my.databasehost.com | |
SET command3=wp db import db/db.sql | |
SET command4=wp search-replace localhost www.mydomain.com.br | |
ECHO %CMDCMDLINE% | FINDSTR /L %COMSPEC% >NUL 2>&1 | |
IF %ERRORLEVEL% == 0 SET interactive=1 | |
:: ssh connect | |
ssh %user%@%hostname% "%command1% && %command2% && %command3% && %command4%" | |
IF "%interactive%"=="0" PAUSE | |
EXIT /B 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment