COME ESEGUIRE COMMANDI IN REMOTO DIRETTAMENTE DA CMD DI WINDOWS

Click to rate this post!
[Total: 1 Average: 4]

Putty e’ un ottimo strumento per collegarsi in remoto ma occorre avere anche plink per esegiuire comandi in remoto direttamente dalla command line cmd

Utilizzando PuTTY dalla riga di comando creerà una sessione SSH interattiva. Questo può non essere quello che vogliamo se per esempio abbiamo bisogno di rimanere sulla linea di comando di Windows o vogliamo emettere un comando SSH all’interno di uno script. Per soddisfare questo tipo di esigenze, PuTTY fornisce uno strumento chiamato Plink

Plink è uno strumento a riga di comando che vi permetterà di accedere a un computer remoto usando SSH e creare una sessione SSH o eseguire un comando, il tutto da linea di comando e senza aprire un’altra finestra. Plink viene fornito con molte opzioni a riga di comando che può essere letta con l’opzione -h…

Il presente articolo descrive dettagliatamente un metodo via VBS e Dos per inviare via telnet comandi remoti

@ECHO OFF
  :: :::::::::::::::::::::::::::::::::::::::::::::
  :: temp_SendKeys.VBS will contain the "commands"
  ECHO.set handler=WScript.CreateObject("WScript.Shell")>temp_SendKeys.VBS
  ECHO.WScript.sleep 500 >>temp_SendKeys.VBS


  :: :::::::::::::::::::::::::::::::::::::::::::::
  :: Open Connection To Telnet Host
  ECHO.handler.SendKeys "open telnet.com~" >>temp_SendKeys.VBS
  ECHO.WScript.sleep 500 >>temp_SendKeys.VBS


  :: :::::::::::::::::::::::::::::::::::::::::::::
  :: Send Login Name
  ECHO.handler.SendKeys "mylogin~" >>temp_SendKeys.VBS
  ECHO.WScript.sleep 500 >>temp_SendKeys.VBS
  :: Send Password
  ECHO.handler.SendKeys "mypassword~" >>temp_SendKeys.VBS
  ECHO.WScript.sleep 500 >>temp_SendKeys.VBS
  

  :: :::::::::::::::::::::::::::::::::::::::::::::
  :: Send Stuff to be done
  ECHO.handler.SendKeys "dir~" >>temp_SendKeys.VBS
  ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS


  :: :::::::::::::::::::::::::::::::::::::::::::::
  :: Logout
  ECHO.handler.SendKeys "exit~" >>temp_SendKeys.VBS
  ECHO.WScript.sleep 250 >>temp_SendKeys.VBS
  ECHO.handler.SendKeys " " >>temp_SendKeys.VBS
  ECHO.WScript.sleep 250 >>temp_SendKeys.VBS
  ECHO.handler.SendKeys "quit~" >>temp_SendKeys.VBS
  ECHO.WScript.sleep 250 >>temp_SendKeys.VBS


  :: Open a Telnet Windows
  start telnet.EXE


  :: Run the script
  cscript//nologo temp_SendKeys.VBS


  :: Delete the temporary file 
  DEL temp_SendKeys.VBS
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x