Operating System - HP-UX
1820539 Members
3680 Online
109626 Solutions
New Discussion юеВ

Re: 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.
tom quach_1
Super Advisor

Re: SSH can not run batch script on windows

Thanks Rex & OldSchool,

Rex the "-B" is not ssh option.
this script here from unix 11.11 to windows and it's still working. the problem is with 11.31 ; the same script won't run.


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

somehow this line did not work before but it run now
ssh -T -v sundc3 ftp33.bat
....
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending command: ftp33.bat
--->and it stays there.

debug1: Entering interactive session.
debug1: Sending command: c:/winuser/ftp33.bat

this
ssh -T -v sundc3 c:\\winuser\\ftp33.bat
becomes this
debug1: Sending command: c:\\winuser\\ftp33.bat


how can i send this "\" to windows




Thanks for your helps.
Tom
Dennis Handly
Acclaimed Contributor

Re: SSH can not run batch script on windows

>the problem is with 11.31

Do you have the same ssh on each? From your debug output, it doesn't look like it.

>how can i send this "\" to windows

First of all put it in single quotes:
'c:\\winuser\\ftp33.bat'

I don't know if ssh will require extra quoting.
tom quach_1
Super Advisor

Re: SSH can not run batch script on windows

Thanks Dennis,

>the problem is with 11.31
--->Yes my 11.11 is still working with the same script

Do you have the same ssh on each? From your debug output, it doesn't look like it.
-->yes the scripts are the same on both servers.

and here is the output.
debug1: Sending command: c:\\\\winuser\\\\ftp33.bat

i did try single, double, forward and backward slash but none is working.
Thanks for your help.
Tom
Dennis Handly
Acclaimed Contributor

Re: SSH can not run batch script on windows

>>Do you have the same ssh on each? From your debug output, it doesn't look like it.

>-->yes the scripts are the same on both servers.

I was saying your ssh is different and that may be the cause.

>i did try single, double

Again, try something that doesn't need a path, like dir.
OldSchool
Honored Contributor

Re: SSH can not run batch script on windows

from the 11.31 box, try to log in via ssh to windows box and run the ftp script manually, as in:

ssh sundc3
c:\>ftp33.bat


What happens?
OldSchool
Honored Contributor

Re: SSH can not run batch script on windows

if the above works, then try the following items from the commmand line on the 11.31 box:

ssh sundc3 ftp33.bat

and

ssh -T sundc3 ftp33.bat


Which (if either) works?
tom quach_1
Super Advisor

Re: SSH can not run batch script on windows

Thank you all,

this command did not work
$ssh sundc3 dir <--

this one work from command line manually
$ssh sundc3
ftp33.bat

this one
$ssh -T sundc3 <--can connect to windows but ican not type anything.

Regards,
Tom
OldSchool
Honored Contributor

Re: SSH can not run batch script on windows

once more:

What happens when you do

ssh sundc3 ftp33.bat

from the command line of the 11.31 box?
tom quach_1
Super Advisor

Re: SSH can not run batch script on windows

ssh sundc3 ftp33.bat

it was just sitting there,

if i run it with
$ssh -v sundc3 ftp33.bat
i can see this, but it just sitting there.

.....
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.
debug1: Sending command: ftp33.bat
...and it just stay there.

Thanks,
Tom


OldSchool
Honored Contributor

Re: SSH can not run batch script on windows

when its just "sitting there" hitting "enter" do anything? (doubtful)

tom quach_1
Super Advisor

Re: SSH can not run batch script on windows

no, nothing happens.
Thanks
tom quach_1
Super Advisor

Re: SSH can not run batch script on windows

Thank you all,