llomll Posted December 15, 2012 Share Posted December 15, 2012 Hi guys, I am new to this forums so hopefully I am asking this questions in the correct forums. I found this script from one of the threads that allows to log into SSH session while using Putty In the background. How do I go about typing in a command after I am logged in? For example, I was to send "ls" command once I am logged in. Any help and guidance is greatly appreciated. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiIPAddress.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("HTSE Login Screen", 331, 238, 326, 220) $Group1 = GUICtrlCreateGroup(" SSH Login", 8, 8, 313, 217) $IP = GUICtrlCreateLabel("IP", 80, 48, 21, 22) GUICtrlSetFont(-1, 11, 800, 0, "Tahoma") $IPAddress1 = _GUICtrlIpAddress_Create($Form1, 104, 48, 130, 21) _GUICtrlIpAddress_Set($IPAddress1, "10.10.10.50") $User = GUICtrlCreateLabel("User", 64, 96, 39, 22) GUICtrlSetFont(-1, 11, 800, 0, "Tahoma") $Username = GUICtrlCreateInput("", 104, 96, 129, 21) $Password = GUICtrlCreateLabel("Password", 24, 136, 77, 22) GUICtrlSetFont(-1, 11, 800, 0, "Tahoma") $Pass = GUICtrlCreateInput("", 104, 136, 129, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD)) $Login = GUICtrlCreateButton("Login", 104, 176, 107, 25) GUICtrlSetFont(-1, 10, 800, 0, "Tahoma") $Cancel = GUICtrlCreateButton("Cancel", 232, 176, 75, 25) GUICtrlSetFont(-1, 10, 800, 0, "Tahoma") $Label1 = GUICtrlCreateLabel("Port", 240, 48, 36, 22) GUICtrlSetFont(-1, 11, 800, 0, "Tahoma") $Input3 = GUICtrlCreateInput("22", 280, 48, 25, 21) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Cancel Exit Case $Login $IPAddress1 = _GUICtrlIpAddress_Get($IPAddress1) $Username = GUICtrlRead($Username) $Pass = GUICtrlRead($Pass) ExitLoop EndSwitch WEnd $Command = "putty.exe -ssh -2 -P 22 " & $Username & "@" & $IPAddress1 & " -pw " & $Pass ;MsgBox(32, 'Command to Pass', $Command & @LF & $IPAddress1) ;comment out this line for production Run($Command) Link to comment Share on other sites More sharing options...
water Posted December 15, 2012 Share Posted December 15, 2012 Haven't used it myself but PLINK (a command-line interface to the PuTTY back ends) seems to be what you need.There is an AutoIt wrapper available for PLINK. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now