Jump to content

Recommended Posts

Posted

Im try to write ssh program but have few issues

is 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 = False

responderOn()

_read()

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button1

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)

$plink = Run("plink.exe -P 22 -l "&$user&" -pw "&$pass&" -ssh "&$host&" "&$command,@ScriptDir, @SW_HIDE, $STDIN_CHILD + $STDERR_CHILD + $STDOUT_CHILD)

EndFunc

In the bold line i need add custom text example user@domain.com

please if anyone have time to help me ?

Regards TM

Posted

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>

Posted

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):

#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>

Posted

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

Posted

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>

Posted

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>

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...