Jump to content

Dont work StdoutRead with Putty.exe


Recommended Posts

$user = "root"
$password =""
$host ="5.0.0.1"
$port ="22"

$puty_exe = @ScriptDir & "\putty.exe"; putty salve local folder script


$command = Run(@comspec & " /C "&$puty_exe&" -ssh -l "&$user&" "&$host&" p "&$port&" -pw "&$password,@ScriptDir, @SW_HIDE, 1)
While 1
$data = StdoutRead($command)
ConsoleWrite($data&@CRLF)
If @error Then ExitLoop
Wend

Why StdoutRead cant read what putty.exe write in console ?

Edited by nill
Link to post
Share on other sites

Because you missed to set parameter opt_flag of the Run statement to $STDOUT_CHILD

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

 

2 hours ago, water said:

Because you missed to set parameter opt_flag of the Run statement to $STDOUT_CHILD

Please give me work example

I try many variants

Edited by nill
Link to post
Share on other sites

Don't know if or where are your misatake(s). Run this script:

$user = "root"
$password = ""
$host = "5.0.0.1"
$port = "22"

$puty_exe = @ScriptDir & "\putty.exe"; putty salve local folder script
If Not FileExists($puty_exe) Then
    ConsoleWrite('putty not found' @CRLF)
    Exit
EndIf

$iPID = Run(@ComSpec & " /C " & $puty_exe & " -ssh -l " & $user & " " & $host & " p " & $port & " -pw " & $password, @ScriptDir@SW_MAXIMIZE, $STDERR_CHILD + $STDOUT_CHILD)
;change back to @SW_HIDE after script is successfully tested
$i = 0
While 1
    $sOutput = StdoutRead($iPID)
    If @error Then ; Exit the loop if the process closes or StdoutRead returns an error.
        ExitLoop
    EndIf
    ConsoleWrite("Stdout Read" & $i & ": " & $sOutput&@CRLF)
WEnd
$i = 0
While 1
    $i += 1
    $sOutput = StderrRead($iPID)
    If @error Then ; Exit the loop if the process closes or StderrRead returns an error.
        ExitLoop
    EndIf
    ConsoleWrite("Stderr Read" & $i & ": " & $sOutput&@CRLF)
WEnd
ConsoleWrite('Finished'&@CRLF)

and post output of the Sciteconsole.

Link to post
Share on other sites

"I try many variants" and "don't help" aren't very informative. Please describe what's going wrong. What are (if any) your error messages? Does it work if you do it manually through the commandline?

One suggestion I would offer is to store the command you're executing in a temporary variable and writing it to the console (ConsoleWrite()) to see if you're actually executing the thing that you meant to execute.

Another suggestion, maybe that's the whole thing, is that the -p parameter for putty requires the dash, so change " p " & $port to " -p " & $port.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to post
Share on other sites

AutoBert

you have erorr in code after i run your code i see this

$PID = Run(@ComSpec & " /C "&$puty_exe&" -ssh -l " & $user & " " & $host & " p " & $port & " -pw " & $password, @ScriptDir^ ERROR

but nothing change i cant read console in autoit

SadBunny

I dont have erorr massage but autoit nothing return in  StdoutRead after I run putty

with  dash  -p I have error

I run another program call vmrun.exe (from VMware) and I can read console

If you can just run putty.exe from autoit maybe I can see simple things

 

Link to post
Share on other sites
1 hour ago, nill said:

you have erorr in code after i run your code i see this

sorry, i didn't test, please test this:

#include <AutoItConstants.au3>

$user = "root"
$password = ""
$host = "5.0.0.1"
$port = "22"

$puty_exe = @ScriptDir & "\putty.exe"; putty salve local folder script
If Not FileExists($puty_exe) Then
    ConsoleWrite('putty not found' &@CRLF)
    Exit
EndIf

$iPID = Run(@ComSpec & " /C " & $puty_exe & " -ssh -l " & $user & " " & $host & " p " & $port & " -pw " & $password, @ScriptDir,@SW_MAXIMIZE, $STDERR_CHILD + $STDOUT_CHILD)
;change back to @SW_HIDE after script is successfully tested
$i = 0
While 1
    $sOutput = StdoutRead($iPID)
    If @error Then ; Exit the loop if the process closes or StdoutRead returns an error.
        ExitLoop
    EndIf
    ConsoleWrite("Stdout Read" & $i & ": " & $sOutput&@CRLF)
WEnd
$i = 0
While 1
    $i += 1
    $sOutput = StderrRead($iPID)
    If @error Then ; Exit the loop if the process closes or StderrRead returns an error.
        ExitLoop
    EndIf
    ConsoleWrite("Stderr Read" & $i & ": " & $sOutput&@CRLF)
WEnd
ConsoleWrite('Finished'&@CRLF)

and please post console output after, mine output is:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\Bert\AutoIt3.My\Test\test.au3" /UserParams    
+>23:58:54 Starting AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0   Keyboard:00000407  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0407)
+>         SciTEDir => C:\Program Files\AutoIt3\SciTE   UserDir => C:\Users\Bert\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Bert\AppData\Local\AutoIt v3\SciTE 
+>Check for missing standard constants/udf include files: 1 include(s) were added
>Running AU3Check (3.3.14.2)  from:C:\Program Files\AutoIt3  input:C:\Users\Bert\AutoIt3.My\Test\test.au3
+>23:58:57 AU3Check ended.rc:0
>Running:(3.3.14.2):C:\Program Files\AutoIt3\autoit3.exe "C:\Users\Bert\AutoIt3.My\Test\test.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
putty not found
+>23:58:57 AutoIt3.exe ended.rc:0
+>23:58:57 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 4.018

 

Link to post
Share on other sites

AutoBert

in outputs i see this

>"C:\Program Files\AutoIt3\SciTE\..\AutoIt3.exe" /ErrorStdOut "C:\Users\ADMIN\Desktop\putty\test_putty.au3"    
Stdout Read0: 
Stdout Read0: 
Stdout Read0: 
Stdout Read0: 
Stdout Read0: 
Stdout Read0: 
Stdout Read0: 
Stdout Read0: 
Stdout Read0: 
Stdout Read0: 
Stdout Read0: 
Stdout Read0: 
Stdout Read0: 

 

many Stdout Read0:  script never end

Link to post
Share on other sites

Use PLink. That's the command line tool for Putty. You'll find a lot of examples on the forum. 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

@Jos, yes: Pscp and plink.  

3.7 The PuTTY command line

       PuTTY can be made to do various things without user intervention
       by supplying command-line arguments (e.g., from a command prompt
       window, or a Windows shortcut).

Look for the verbose mode. putty command line

GUI Putty should have a tick box for a log file. It may help to force putty into verbose mode.  See if you can log the output to a file.  Read the file afterwards.

 

Skysnake

Why is the snake in the sky?

Link to post
Share on other sites

It does not work with putty, only with plink. I've tried running it with putty for ages and failed. Since i don't have code in hand, i will describe how it works - open putty, save some session, then launch the plink proccess with the same session name. Write to sdin, wait some time , close proccess and then read stdout and stderr.

#include <constants.au3> ; not sure where was the child stuff stored
$somepid = run("c:\path\to\plink.exe -batch NameOfYourStoredConnection ","c:\path\to\", @sw_show $STDIN_CHILD + $STDOUT_CHILD + $STDERR_CHILD)
StdinWrite($somepid,"do stuff here")
sleep(100)
ProccessClose($somepid)
ProccessWaitClose($somepid)
$Output = StdoutRead($somepid)
$Error = StderrRead($somepid)
consolewrite("output - " & $Output & @CRLF)
consolewrite("error (if any) - " & $Error & @CRLF)
exit

Something like this (quick writed in box, hope you get the idea)

Edit : typos, i need english dictionary :D

Edited by JustSomeone
Link to post
Share on other sites

water

JustSomeone

 

try to use plink.exe instead putty.exe

#include <AutoItConstants.au3>

$user = "root"
$password = "pass"
$host = "1.1.1.1"
$port = "22"

$puty_exe = @ScriptDir & "\plink.exe"; putty salve local folder script
If Not FileExists($puty_exe) Then
    ConsoleWrite('putty not found' &@CRLF)
    Exit
EndIf

$iPID = Run(@ComSpec & " /C " & $puty_exe & " -ssh -l " & $user & " " & $host & " p " & $port & " -pw " & $password, @ScriptDir,@SW_MAXIMIZE, $STDERR_CHILD + $STDOUT_CHILD)
;change back to @SW_HIDE after script is successfully tested
$i = 0
While 1
    $sOutput = StdoutRead($iPID)
    If @error Then ; Exit the loop if the process closes or StdoutRead returns an error.
        ExitLoop
    EndIf
    ConsoleWrite("Stdout Read" & $i & ": " & $sOutput&@CRLF)
WEnd
$i = 0
While 1
    $i += 1
    $sOutput = StderrRead($iPID)
    If @error Then ; Exit the loop if the process closes or StderrRead returns an error.
        ExitLoop
    EndIf
    ConsoleWrite("Stderr Read" & $i & ": " & $sOutput&@CRLF)
WEnd
ConsoleWrite('Finished'&@CRLF)

I get this text in autoit console

Stdout Read0: root@1.1.1.1's password: 

but why i cant login in on server ?

when I use this in putty.exe all is ok I login on server

when I mannually run plink.exe password requires too

 

I cant use StoredConnection like in JustSomeone example

Link to post
Share on other sites
  • Developers

You are not having the correct parameter for port: change the " p " to " -P ".

$iPID = Run(@ComSpec & " /C " & $puty_exe & " " & $host & " -ssh -l " & $user & " -pw " & $password & " -P " & $port , @ScriptDir,@SW_MAXIMIZE, $STDERR_CHILD + $STDOUT_CHILD + $STDIN_CHILD )

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By JiBe
      Hi to all,
       
       
      I only am accustomed pas has posted on the forum (coz, I'm french). But I use it a lot.
      So first of all, thank you all to participate in the evolution of this wonderful product.
      Today is not one day like any other, I myself am decide has posted a UDF that I myself create and developed (there may be some bug) for some months.
      So here it is:
      This UDF allows to use the SSH protocol very easily in your code.
      It uses the syntax as the TCPxxx() function.
      Your code will be easier to convert :-).
       
      excused my English, I'm French.
       
      Example:
       
      #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.4.0 Author: Joseph Barone 2010-2015 Script Function: Modele pour l'utilisation de la fonction ssh (plink). #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include #include #include #include #include #include "SSH_udf.au3" _SSHStartup() Global $butt[6] $Gui = GUICreate("SSH Console",550,400) $label1 = GUICtrlCreateLabel("Adresse IP:",10,10,150,20) ; ip $input1 = GUICtrlCreateInput("",10,25,150,20) ; ip $label2 = GUICtrlCreateLabel("Tcp port:",170,10,150,20) ; port $input2 = GUICtrlCreateInput("",170,25,60,20) ; port $label6 = GUICtrlCreateLabel("Protocol:",240,10,40,20) ; port $input6 = GUICtrlCreateInput("ssh",240,25,60,20) ; port $butt[0] = GUICtrlCreateButton("Connect0",310,5,80,20,$BS_DEFPUSHBUTTON) $butt[1] = GUICtrlCreateButton("Connect1",390,5,80,20) $butt[2] = GUICtrlCreateButton("Connect2",470,5,80,20) $butt[3] = GUICtrlCreateButton("Connect3",310,25,80,20) $butt[4] = GUICtrlCreateButton("Connect4",390,25,80,20) $butt[5] = GUICtrlCreateButton("Connect5",470,25,80,20) $Checkbox = GUICtrlCreateCheckbox("RSA, Fingerprint, Alert AutoValidate", 330, 45, 205, 25) $label4 = GUICtrlCreateLabel("Login:",10,45,150,20) ; login $input4 = GUICtrlCreateInput("",10,60,150,20) ; login $label5 = GUICtrlCreateLabel("Mot de passe:",170,45,150,20) ; password $input5 = GUICtrlCreateInput("",170,60,150,20,$ES_PASSWORD) ; password $label3 = GUICtrlCreateLabel("Commande a envoyer:",10,85,150,20) ; send command $input3 = GUICtrlCreateInput("",10,100,310,20) ; send commande vers l'hote $butt2 = GUICtrlCreateButton("Send",330,100,80,20,$BS_DEFPUSHBUTTON) GUICtrlSetState($butt2,$GUI_DISABLE) $edit = GUICtrlCreateEdit("",10,130,530,260,$WS_VSCROLL);,$WS_DISABLED)) GUISetState() Global $ConnectedSocket[6] = [-1,-1,-1,-1,-1,-1] Global $msg, $recv, $ret ; GUI Message Loop ;============================================== While 1 $nmsg = GUIGetMsg() If $nmsg = $GUI_EVENT_CLOSE Then ExitLoop ;;; connect part: $b = 0 While 1 If $nMsg = $butt[$b] Then If GUICtrlRead($butt[$b]) = "Connect"&$b Then _SSHParametreSet("yesall",GUICtrlRead($Checkbox)) _SSHParametreSet("protocol",GUICtrlRead($input6)) _SSHParametreSet("login",GUICtrlRead($input4)) _SSHParametreSet("passwd",GUICtrlRead($input5)) $ConnectedSocket[$b] = _SSHConnect(GUICtrlRead($input1),GUICtrlRead($input2)) If $ConnectedSocket[$b] = 0 Then MsgBox(0,"Erreur", "Impossible de ce connecter!!") Else GUICtrlSetData($butt[$b],"Close"&$b GUICtrlSetState($butt2,$GUI_ENABLE) EndIf DisplayArray($_config) ConsoleWrite("nb config:"&$_nbconf&@CRLF) Else _SSHCloseSocket($ConnectedSocket[$b]) GUICtrlSetData($butt[$b],"Connect"&$b GUICtrlSetState($butt2,$GUI_DISABLE) DisplayArray($_config) ConsoleWrite("nb config:"&$_nbconf&@CRLF) EndIf EndIf ;;; send part: If $nMsg = $butt2 Then $ret = _SSHSend( $ConnectedSocket[$b] , GUICtrlRead($input3)&@crlf) GUICtrlSetData($input3,"") GUICtrlSetState($input3,$GUI_FOCUS) EndIf ;;; receive part: $recv = _SSHRecv( $ConnectedSocket[$b]) If $recv <> "" Then GUICtrlSetData($edit, GUICtrlRead($edit) & $recv ) EndIf GUICtrlSendMsg($edit, $EM_SCROLL, $SB_PAGEDOWN, 0) $b += 1 If $b = UBound($butt) Then ExitLoop WEnd WEnd _SSHCloseSocket($ConnectedSocket) _SSHShutdown() Exit Func DisplayArray($array) $i = 0 $j = 0 if UBound($array,1) = 0 Then Return While 1 ConsoleWrite("(["&UBound($array,1)&"]["&UBound($array,2)&"]) ") While 1 ConsoleWrite("["&$j&"]"&$array[$i][$j]&" ") $j += 1 if UBound($array,2)<=$j Then ExitLoop WEnd ConsoleWrite(@CRLF) $i += 1 $j = 0 if UBound($array,1)<=$i Then ExitLoop WEnd EndFunc   
      I join with UDF version of modified putty myself.  🙂 LoL
      but, it is not used with the UDF, it is included in the UDF.
       
      putty-04012015- 92453+lic.zip
      ssh_udf.zip
      New version (contains the latest version of plink (0.74) edited by http://jakub.kotrla.net/putty/) 
      ssh_udf-v2.zip
      Same as the v2 but supports all putty/plink settings
      ssh_udf-v2.1.zip
    • By GillesMaisonneuve
      Good morning,
       
      I am trying to read a Unicode utf8 string from a perl subprocess via StdoutRead.
      I use an AUtoIt GUI and display result in an 'Edit' control (see my code below) using 'Courier New', a font that can handle Unicode characters.
      I was expecting a result looking like (CMD console):
      ++$ chcp 65001>NUL: & perl -Mutf8 -CS -e "use 5.018; binmode STDOUT,q(:utf8); say qq(\x{03A9})" & chcp 850>NUL: Ω Instead I get someting like this (see downward the screen copy):
      ++$ chcp 1250>NUL: & perl -Mutf8 -CS -e "use 5.018; binmode STDOUT,q(:utf8); say qq(\x{03A9})" & chcp 850>NUL: Ω Obviously while I was expecting to receive an utf8 char, it seems to have been converted to Windows ANSI codepage 1250 (Windows default for Western/Central Europe, right ?)
      What am I doing wrong? Is there someone who could guide me?
       
      Here is my code and my output in the GUI.
      Creating and configuring the Edit control:
      Local $Edit1 = GUICtrlCreateEdit( "", 20, 110, 780, 500, BitOr($GUI_SS_DEFAULT_EDIT,$ES_MULTILINE,$ES_READONLY) ) GUICtrlSetData($Edit1, "This field will contain text result from external Perl command") GUICtrlSetFont($Edit1, 10, $FW_THIN, $GUI_FONTNORMAL, "Courier New")  
      Executing Perl command (note: `-Mutf8` and `-CS` garantees that I work in utf8 and STDOUT accepts wide-characters):
      local $ExePath = 'perl.exe -Mutf8 -CS ' ;~ if perl in PATH, no need for full path C:\Perl\bin\perl.exe local $Params = '-e "use 5.018; use utf8; use charnames q(:full); binmode STDOUT,q(:utf8);' & _ 'say scalar localtime; say qq(\N{GREEK CAPITAL LETTER OMEGA})"' local $Cmd = $ExePath & ' ' & $Params Local $iPID = Run($Cmd, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD))  
      Reading STDOUT and displaying it into the Edit control:
      While 1 $sOutput &= StdoutRead($iPID) If @error Then ; Exit the loop if the process closes or StdoutRead returns an error. ExitLoop EndIf WEnd If $sOutput <> '' Then GUICtrlSetData($Edit1, $sOutput) EndIf  
      And now, what I get on my GUI:
       

    • By Funtime60
      I have a Parent Script that starts multiple, concurrent child processes. I cannot figure out how to apply the technique for using StdoutRead in the examples in a way that listens to them all simultaneously.
      For reference, there can be any even number of, or single, child processes and there is an 1D array, $PIDS, that stores the PIDS of all the child processes and they should be outputting to another 1D array $sOutput.
      Thank you for your time. Please just point me in the right direction. I'm sorry if I missed another topic that covers this.
    • By Blueman
      Hey Guys,

      I have a (i think) simple question, but i can't seem to get the answer though the help-files.
      Hope that you can help me with this issue.
      - I am opening a SSH Connection with the following function
      Func _Connect($session,$usr,$pass) $exec = @ScriptDir & "\PLINK.EXE" If Not FileExists($exec) Then _Err("PLINK.EXE Not Found!",0) $pid = Run($exec & " -load " & $session & " -l " & $usr & " -pw " & $pass, @ScriptDir, @SW_HIDE, 0x1 + 0x8) ;Run SSH.EXE If Not $pid Then _Err("Failed to connect",0) $currentpid = $pid ;$rtn = _Read($pid) ;Check for Login Success - Prompt ;MsgBox(48,"","1") ;sleep(5000) ;Wait for connection Return $pid EndFunc - This will connect to a CMS Server with a vt100 interface where a dynamic report is generated every 20 seconds.
      - Then i will read the contents with the following Function
      Func _Read($pid) $SSHREADTIMEOUT = 0 If Not $pid Then Return -1 Local $dataA Local $dataB Do $SSHREADTIMEOUT += 1 $dataB = $dataA sleep(100) $dataA &= StdOutRead($pid) If @error Then ExitLoop Until ($dataB = $dataA And $dataA And $dataB) OR $SSHREADTIMEOUT == 50 Return $dataA EndFunc This all goes correctly, but i can only read the contents once.
      When i try to read the contents again i get nothing.
      Maybe because the CMS isn't changing, but the values in the report is changing every 20 seconds.
      I need to somehow read al of the contents every time i perform a Read action, but how?
      Yes, i can use it in a While loop, but also then i get nothing or a small line of text and not the whole report.
       
      Any Idea?
       
      Thanks Guys!
       
      --Edit--
      I have fixed the problem by changing the terminal session to a vt220 session.
      The only problem now is that i want to send the: "Data link escape" command and that is something i cannot fix,.
      I have tried;
      StdinWrite($Pid,Hex(0x10)) StdinWrite($Pid,Chr(16)) StdinWrite($Pid,{DLE}) But nothing seems to work.  
      -- Edit-2 --
      Guys, fixed that too!
      Forgot to add the number '5' to actually execute the assignment.
      So fixed it by using;
       
      StdinWrite($Pid,Chr(16)) StdinWrite($Pid,"5")
      Thanks for reading with me
       
    • By rudi
      Hello,
      to provide an easy to use starter to capture traffic on all NICs found, I can successfully get all the interfaces of TSHARK.EXE (the command line version that's automatically installed along with wireshark) with this script:
      #include <AutoItConstants.au3> #include <Array.au3> $TS_WD = "C:\Program Files\Wireshark" $TS_exe = $TS_WD & "\tshark.exe" if not FileExists($TS_exe) Then MsgBox(48,"Fatal Error","No Wireshark Commandline Tool ""TSHARK.EXE"" found:" & @CRLF & _ $TS_exe) Exit EndIf $DString = "" $PIDGetIFs = Run($TS_exe & " -D", $TS_WD, @SW_HIDE, $STDERR_MERGED) While ProcessExists($PIDGetIFs) $DString &= StdoutRead($PIDGetIFs) WEnd ; MsgBox(0,"IFs",$DString) $aNICs = StringSplit($DString, @CRLF, 1) _ArrayDisplay($aNICs) $RegExIF = "^(?:\d+\. )(\\.*?})(?: \()(.*?)(\))$" ; $1 = TSHARK Interface Name, $2 = Windows Interface Name ; ... get the names to run TSHARK with the appropriate interface string  
      When I run TSHARK.EXE using this line directly, I see a continuously growing number telling the number of packets captured so far.
      "C:\Program Files\Wireshark\tshark.exe" -i \Device\NPF_{AEB931E9-E5FA-4DA5-8328-D87BDF53805C} -b duration:300 -b files:600 -w "y:\TShark-Ringbuffer\LAN-Verbindung\TSHARK-Com-0317_17---LAN-Verbindung___.pcap" Using this script, I *DO* see the first output line "Capturing on 'LAN-Verbindung'", but I cannot get hold of the continuously growing number of packets captured so far.
      #include <AutoItConstants.au3> $WD="C:\Program Files\Wireshark" $CMD='"C:\Program Files\Wireshark\tshark.exe" -i \Device\NPF_{AEB931E9-E5FA-4DA5-8328-D87BDF53805C} -b duration:300 -b files:600 -w "y:\TShark-Ringbuffer\LAN-Verbindung\TSHARK-Com-0317_17---LAN-Verbindung___.pcap"' ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $CMD = ' & $CMD & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $PID=Run($CMD,$WD,@SW_SHOW,$stderr_merged) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $PID = ' & $PID & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $OutputAll="" While ProcessExists($PID) $output=StdoutRead($PID) $OutputAll&=$output ToolTip($OutputAll) if $output <> "" then ConsoleWrite("""" & $output & """" & @CRLF) Sleep(1000) WEnd ConsoleWrite("Process vanished" & @CRLF)  
      This is the output of SciTE, when I let TSHARK.EXE run for a short while, the "close" it's "box" ...
       
      --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop @@ Debug(10) : $CMD = "C:\Program Files\Wireshark\tshark.exe" -i \Device\NPF_{AEB931E9-E5FA-4DA5-8328-D87BDF53805C} -b duration:300 -b files:600 -w "y:\TShark-Ringbuffer\LAN-Verbindung\TSHARK-Com-0317_17---LAN-Verbindung___.pcap" >Error code: 0 @@ Debug(13) : $PID = 10948 >Error code: 0 "Capturing on 'LAN-Verbindung' " Process vanished  
      Howto catch the "growing-packet-number" TSHARK.EXE is writing continuously to the same "window position"???
       
       
      Regards, Rudi.
       


×
×
  • Create New...