Anuj Kaushal

How to open server bash inside local shell script

July 26, 2020, by anuj, category Bash, Blog

Its always tricky to start deployment operation on local and perform few steps on server bash and i was looking for a way to write all local and server commands inside a single deployment file. Finally i was able to do that using following code.

The trick is open and close “SSHBASH” every command inside this runs on the server.

Here is the expected output

$ sh main.sh
SEVER BASH - stats here
Pseudo-terminal will not be allocated because stdin is not a terminal.
Successfully connected to example.com
-rw-r--r-- 1 username username 685 Jul 22 17:50 ./public_html/index.html
Echo Var1 Value: important-value
Successfully disconnected from example.com