At my work, I usually use a simple command trough Putty to restart a server for several reasons :
sudo /sbin/allowed user kill servername
This command basically calls the command "kill servername" from another user.
Now the problem is, I want run Putty trough a windows command line to be able to run a remote task by Hudson, that will call a .bat file etc...
So after some reading, I realised Putty offers a program called "Plink", that allows to use Putty directly into the command line. So i did a .bat file that
does this :
C:
cd C:\programs\Putty
plink -l userHERE -pw passwordHERE -m commands.txt server
This command is really simple, it uses the cmd.exe to connect trough Putty, on "server", with the user "userHERE" and the password "passwordHERE".
This part works great, I actually see the Putty interface built in the cmd.exe, but the "-m commands.txt" means that I wanna run all the commands in
the file trough Putty.
This my the content of commands.txt
sudo /sbin/allowed user kill servername
Problem is :
"kill servername" ask for a confirmation if I really wanna kill the server, I see the question pop in the command line, but i can't type nothing !
Even if I do it directly with Putty instead of Plink, the program will run in a new Putty window, but I am not able to answer to confirmation, even If
I add the command "yes" in commands.txt, it won't reads any commands after the "sudo /sbin/allowed user kill servername" command...Even if I just
try a standart "echo test", nothing will happen since it's jammed on the confirmation....
Anyone can help ?
Thanks,
Simon.