danfreak
danfreak

Reputation: 415

ssh connection and remote output in local shell

I would like to run a local command file remotely and get the output locally in my shell window.

Actually the command executes remotely but I do not see the results in my local shell/console window.

Any idea on how to implement the following command?

ssh user@host 'bash -s' < /Users/daniel/bin/bash/fz_multiple_db_connections.sh 

Where fz_multiple_db_connections.sh contains:

#!/bin/bash
connections=(
             'mysql -u dbuser__name      --password=passw   dbname ' 
             'mysql -u dbuser__name1     --password=passw1  dbname1')

for f in "${connections[@]}"
do
    echo `${f}`
    echo `mysql show tables`
    echo `mysql exit`
done
exit

Upvotes: 0

Views: 825

Answers (2)

twalberg
twalberg

Reputation: 62369

I think you'll probably need to do ssh -t .... to allocate a tty. Programs that strictly write to stdout or std::cout should work fine without the -t, but if the program you're running needs access to /dev/tty (or any of it's equivalents), for example, to ask for a password or something, you need the -t option to ssh.

Upvotes: 1

Related Questions