Question : Problem: Automating a login and single command to my firewall using Putty/Plink OR Telnet?

Hi,

I need to write a script that connects to my firewall (a Netscreen 25) and sends it a single command (a manual DNS refresh). I've been guided so far to use Putty/Plink, but have got stuck about how to proceed.

I plan to connect using SSH or Telnet protocol. Using SSH with plink, I can pass the username and password and hostname as parameters in the command line, but also want to pass a single command as well, e.g.

plink -ssh HOSTNAME - l LOGIN - pw PASSWORD     .......SINGLE LINE COMMAND HERE....

My question is, is this possible? Or do I haave to get into the realms of linking to external files of commands, or automating a session using putty etc? I'm after a simple quick solution for this!

Thanks

Answer : Problem: Automating a login and single command to my firewall using Putty/Plink OR Telnet?

Here is a VBScript that should do what your looking for. Just remember your creditials are in plain text in the script, set your permissions accordiningly:

set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run "C:\putty HOSTNAME -l LOGIN -pw PASSWORD"      ' put putty in C:\
WScript.Sleep 2000
WshShell.AppActivate "HOSTNAME - PuTTY"      'insert correct hostname
WshShell.SendKeys "command"             'insert dns refresh command
 WScript.Sleep 100
 WshShell.SendKeys "{ENTER}"
WScript.Sleep 1000
 WshShell.SendKeys "exit"
WScript.Sleep 100
WshShell.SendKeys "{ENTER}"

You will need to put putty in you C:\ directory or give it an absolute path

Good Luck

Darkstriker69
Random Solutions  
 
programming4us programming4us