I am working on remotely executing a command line in Windows from Debian. For that, I tried to use the bash script below. Using the expect tool, it consists in connecting via telnet to the remote server, entering username and password values and sending the command line desired.
#!/usr/bin/expect
set timeout 20
set name 192.168.1.46
set user Administrateur
set password MSapp/*2013
set cmd "TASKKILL /F /IM Tomcat6.exe"
spawn telnet 192.168.1.46
expect "login:"
send "$user\r"
expect "password:"
send "$password\r"
expect "C:\Users\Administrateur>"
send "$cmd\r"
The telnet connection is well established. But, the command line is not executed.
Could someone tell me what is wrong with my script?