AKIWEB AKIWEB - 4 years ago 167
Bash Question

Ssh to remote server through windows batch

Can anyone suggest me how I can use Windows Batch Program to

ssh
to remote server and then execute
shell scripts
over there?

Any simple sample example will be good for me to start on this.

Server Name:-
ares-ingest.vip.host.com


Username:-
uname


Password:-
password


Any suggestions will be appreciated as I am new to Windows Batch Program

Update:-

I tried using
plink
to execute the shell script that I have on my local machine and I always get the error like below, Is there anything wrong I am doing?

C:\PLINK>plink uname@cli.host.com -m email.sh
Using keyboard-interactive authentication.
Password:
Using keyboard-interactive authentication.
Your Kerberos password will expire in 73 days.

sh: HIVE_OPTS= -hiveconf mapred.job.queue.name=hdmi-technology: is not an identifier


Below is the content in my shell script-

#!/bin/bash
export HIVE_OPTS="$HIVE_OPTS -hiveconf mapred.job.queue.name=hdmi-technology"
hive -S -e 'SELECT count(*) from testingtable2' > attachment.txt

Answer Source

try using plink to send your commands over.

Usage: plink [options] [user@]host [command]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download