tattooman Posted June 22, 2011 Share Posted June 22, 2011 Im try to write ssh program but have few issuesis it possible to add to the end of command string from input ?the code itself is here#include <ButtonConstants.au3>#include <EditConstants.au3>#include <GUIConstantsEx.au3>#include <WindowsConstants.au3>#include <Constants.au3>#include <plink.au3>#include <file.au3>#Region ### START Koda GUI section ### Form=HotKeySet('`',"_read"); hit this button to read your input after hitting enter(tilde button)$Form1 = GUICreate("ParagonPOS Autoresponder", 625, 443, 192, 124)$Button1 = GUICtrlCreateButton("Autoresponder ON", 112, 96, 145, 33, $WS_GROUP)$Button2 = GUICtrlCreateButton("Autoresponder OFF", 336, 96, 145, 33, $WS_GROUP)$Input = GUICtrlCreateInput("", 232, 48, 121, 21)GUISetState(@SW_SHOW)#EndRegion ### END Koda GUI section ###Global $plink$_plink_logging=true$user = "";username$pass = "";password$host = "";host$command = "/usr/local/psa/bin/autoresponder --on"$read = FalseresponderOn()_read()While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 responderOn() Case $Button2 responderOff() EndSwitch Sleep(20)WEndfunc responderOn() while 1 $msg = StdoutRead($plink) if @error then ExitLoop if $msg <> "" Then ConsoleWrite($msg) EndIf if $read Then StdinWrite($plink,ConsoleRead()) $read=False EndIf sleep(25)WEndStdioClose($plink)$plink = Run("plink.exe -P 22 -l "&$user&" -pw "&$pass&" -ssh "&$host&" "&$command,@ScriptDir, @SW_HIDE, $STDIN_CHILD + $STDERR_CHILD + $STDOUT_CHILD) EndFuncIn the bold line i need add custom text example user@domain.complease if anyone have time to help me ?Regards TM Link to comment Share on other sites More sharing options...
sleepydvdr Posted June 22, 2011 Share Posted June 22, 2011 You should be able to do it. I'm just guessing at what you want your outputted string to look like, but here's an example: $input = InputBox("My Input", "Enter your username (ex: user@domain.com): ") ... $command = "/usr/local/psa/bin/autoresponder" & $input & " --on" #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
sleepydvdr Posted June 22, 2011 Share Posted June 22, 2011 Actually, I just played with your code and I think this may work (again, I don't know what the output of the $command variable should be): expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <plink.au3> #include <file.au3> #Region ### START Koda GUI section ### Form= HotKeySet('`', "_read"); hit this button to read your input after hitting enter(tilde button) $Form1 = GUICreate("ParagonPOS Autoresponder", 625, 443, 192, 124) $Button1 = GUICtrlCreateButton("Autoresponder ON", 112, 96, 145, 33, $WS_GROUP) $Button2 = GUICtrlCreateButton("Autoresponder OFF", 336, 96, 145, 33, $WS_GROUP) $Input = GUICtrlCreateInput("", 232, 48, 121, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $plink $_plink_logging = True $user = "";username $pass = "";password $host = "";host $read = False responderOn() _read() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Input = GUICtrlRead($Input) ; added this line responderOn() Case $Button2 responderOff() EndSwitch Sleep(20) WEnd Func responderOn() While 1 $msg = StdoutRead($plink) If @error Then ExitLoop If $msg <> "" Then ConsoleWrite($msg) EndIf If $read Then StdinWrite($plink, ConsoleRead()) $read = False EndIf Sleep(25) WEnd StdioClose($plink) $command = "/usr/local/psa/bin/autoresponder" & $Input & " --on" ; Moved this line because the input was not given before running this function $plink = Run("plink.exe -P 22 -l " & $user & " -pw " & $pass & " -ssh " & $host & " " & $command, @ScriptDir, @SW_HIDE, $STDIN_CHILD + $STDERR_CHILD + $STDOUT_CHILD) EndFunc ;==>responderOn #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
tattooman Posted June 23, 2011 Author Share Posted June 23, 2011 the syntax is /usr/local/psa/bin/autoresponder --off user@domain.com i try here diiferent things seems not working . Basicly it needs add user@domain.com after command and feeed to plink Link to comment Share on other sites More sharing options...
sleepydvdr Posted June 23, 2011 Share Posted June 23, 2011 Ah, I think you need to add quotes because of the spaces in the statement: $command = '"' & "/usr/local/psa/bin/autoresponder --on " & $Input & '"' #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
tattooman Posted June 23, 2011 Author Share Posted June 23, 2011 Thank you it worked but it runs only once then i need reset program is that normal ? Link to comment Share on other sites More sharing options...
sleepydvdr Posted June 23, 2011 Share Posted June 23, 2011 The Gui should continue running. Have you added any more exit statements since the first post? Is there more code that could exit? From what you have shown, there is only Exit in that code. Otherwise, it will run indefinitely. #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
tattooman Posted June 23, 2011 Author Share Posted June 23, 2011 the whole code is there http://pastebin.com/jGaAUa1c please if u have time look it 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