Operating System - HP-UX
1752777 Members
6153 Online
108789 Solutions
New Discussion юеВ

SSH can not run batch script on windows

 
tom quach_1
Super Advisor

SSH can not run batch script on windows

dear all,

Please help me on this issue.
this script will run from HPUX 11.11 to windows 2003 using SSH (SSH installed and configured on windows)
what it does is to ssh to host (sundc3) and run the batch script (fpt33.bat) this script will ftp to HPUX and pickup a file to windows.

#!/bin/sh
#set -x
sleep 2;
ssh -T sundc3 <ftp33.bat
EOF

this one is working fine on HPUX 11.11
i am moving to 11.31
doing the same thing, the windows server is still the same but the HPUX is now on new server HPUX itanium 11.31
the problem that i have now is, the script ran fine on Itanium, no error, but it did not run the batch file from windows.
here is how i ran the script
$./winuser.sh
Received disconnect from 10.10.2.23: 2: disconnecting

if i run this command from command line
$ssh -T sundc3
it will connect to windows no problem.
or if i run the batch file from windows, it will connect to HPUX 11.31 noproblem.
so the problem seems somwwhere in the script.
Please Help!
Regards,
Tom

21 REPLIES 21
Ivan Krastev
Honored Contributor

Re: SSH can not run batch script on windows

Try to use in script:

ssh -T sundc3 ftp33.bat

Also check with -v option to see more details.

regards,
ivan
tom quach_1
Super Advisor

Re: SSH can not run batch script on windows

Thanks Ivan,

Without "<<" it won't run
with -v i can see more detail.
it seems like the connection is fine, but it could not run the bat file on windows.
Any idea Please!



$./winuser.sh.bk
+ sleep 2
+ ssh -T -v sundc3
+ 0< /var/tmp/sh4637.1
OpenSSH_4.7p1+sftpfilecontrol-v1.2-hpn12v17, OpenSSL 0.9.7m 23 Feb 2007
HP-UX Secure Shell-A.04.70.023, HP-UX Secure Shell version
debug1: Reading configuration data /opt/ssh/etc/ssh_config
debug1: Connecting to sundc3 [10.10.2.23] port 22.
debug1: Connection established.
debug1: identity file /home/winuser/.ssh/id_rsa type 1
debug1: identity file /home/winuser/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version SysaxSSH_1.0
debug1: no match: SysaxSSH_1.0
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.7p1+sftpfilecontrol-v1.2-hpn12v17
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'sundc3' is known and matches the RSA host key.
debug1: Found key in /home/winuser/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /home/winuser/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: Final hpn_buffer_size = 131072
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
Received disconnect from 10.10.2.23: 2: disconnecting
itauxap1:[winuser]:[TWO_TASK=SAP]:/home/winuser
$
Dennis Handly
Acclaimed Contributor

Re: SSH can not run batch script on windows

>but it could not run the bat file on windows.

Can you add something like a "dir" command before your ftp33.bat?
The last things we see are:
debug1: Entering interactive session.
Received disconnect from 10.10.2.23: 2: disconnecting
tom quach_1
Super Advisor

Re: SSH can not run batch script on windows

Thanks Dennis,

if i add the dir before the sundc3 then it think the dir is the host and got an error.
with this line, it get me to windows dir
$ssh -T -v sundc3

Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\winuser>

try to run from command line, how can i run
this line below
$ssh -T -v sundc3 <
Thanks,
Tom
Dennis Handly
Acclaimed Contributor

Re: SSH can not run batch script on windows

>if i add the dir before the sundc3

Sorry I meant:
ssh -T sundc3 <dir
ftp33.bat
EOF
tom quach_1
Super Advisor

Re: SSH can not run batch script on windows

Thanks Dennis,

It does not work.

and here is the debug from working UNIX server, they are identical.


$./wwwsundc3.sh
OpenSSH_4.1, OpenSSL 0.9.7e 25 Oct 2004
HP-UX Secure Shell-A.04.00.000, HP-UX Secure Shell version
debug1: Reading configuration data /opt/ssh/etc/ssh_config
debug1: Connecting to sundc3 [10.10.2.23] port 22.
debug1: Connection established.
debug1: identity file /home/batchus/.ssh/id_rsa type 1
debug1: identity file /home/batchus/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version SysaxSSH_1.0
debug1: no match: SysaxSSH_1.0
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'sundc3' is known and matches the RSA host key.
debug1: Found key in /home/batchus/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /home/batchus/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 149
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
Received disconnect from 10.10.2.23: 2: disconnecting
rmueller58
Valued Contributor

Re: SSH can not run batch script on windows

Try using the -B (for BATCH) in your ssh script.
tom quach_1
Super Advisor

Re: SSH can not run batch script on windows

Hi

Can someone please helps me on this issue

Thanks,
Tom

OldSchool
Honored Contributor

Re: SSH can not run batch script on windows

if the script ftp33.bat exists on the windows box, then a script like:

#!/bin/sh
#set -x
sleep 2;
ssh sundc3 full/path/to/ftp33.bat

ought to work, i would think.

I must admit, I've not seen an example where "here-doc" works in the fashion you described.