Hi,
My goal is to connect from unix server A to windows server B and call a bat file on windows.
I am able to succeed in remoting to windows and executing a command, the issue i am facing is the shell scrip is exiting without making sure of bat file success.
Can you please help me in modifying the below script or suggest something better to execute command on remote machine and wait for its success/failure.
#!/usr/bin/bash
HOST="localhost"
USER="username"
PASS="pass"
CMD=$@
VAR=$(expect -c "
spawn ssh -o PreferredAuthentications=password -o StrictHostKeyChecking=no $USER@$HOST $CMD
match_max 100000
expect \"*?assword:*\"
send -- \"$PASS\r\"
expect "\\$"
expect -re "$USER.*"
send "logout"
")
sample .bat file i am using for test is
@echo off
ping 127.0.0.1
if "%errorlevel%"=="0" cls &Echo %errorlevel%
if "%errorlevel%"=="1" cls &Echo %errorlevel%
timeout /t 60
Thanks a lot in advance