简体   繁体   中英

How to get complete console output from remote machine via SSH

I have a normal bash script which deploys my locally developed application to a test server. The script looks like this.

#!/usr/bin/env bash

ssh username@192.168.0.x "cd /my/directory/api && npm install"
ssh username@192.168.0.x "cd /my/directory/api && npm run build"
ssh username@192.168.0.x "cd /my/directory/api && npm run schema:drop"
ssh username@192.168.0.x "cd /my/directory/api && mysql -u username database_name < dump.sql"

Now I want to get the output of this commands on my locale terminal. But I only get some output when the commands fails. How can I get the complete output?

Running repeated ssh commands to the same host is clumsy and inefficient anyway.

ssh username@192.168.0.x "
    set -e  # abort on any failure
    cd /my/directory/api
    npm install
    npm run build
    npm run schema:drop
    mysql -u username database_name < dump.sql" >output.log 2&>1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM