Sign in to follow this  
Followers 0
boomingranny

Help, i can't send/recieve StdoutRead / stdinwrite info!

4 posts in this topic

Hi,

I have spent the last 5 hours trying to make this script read the text from this Microsoft console app called "dhcploc.exe"

(it searches for DHCP servers running on your network)

My current conclusion is, that there are just some programs that, alhough they output to the console window

you cannot send text/recieve text via StdinWrite/StdoutRead

What dhcploc does, when your press d is it sends a dhcp request to your network,

it then displays any dhcp servers running on your network...

so in my code i am running it, trying to send d, then read the reply

(please don't suggest i just use send(), that isn't an option here)

The code i currently have is as follows:

DirCreate ("tools");just incase
FileInstall ("dhcploc.exe",@ScriptDir&"\tools\dhcploc.exe")
ProcessClose ("dhcploc.exe")
$dhcploc = Run(@ScriptDir&"\tools\dhcploc.exe "&@ComputerName ,"",@SW_SHOW,9) 
 Sleep (500)
 
 $data = ""
 StdinWrite($dhcploc, "d"&@CRLF)
 StdinWrite ($dhcploc,"")

 While $dhcploc
    $tmp =  StdoutRead($dhcploc)
    $data &= $tmp
    ConsoleWrite ($tmp)
    Sleep (25)
WEnd

Thanks for taking the time to help :P

dhcploc.exe

Share this post


Link to post
Share on other sites



Hi,

I have spent the last 5 hours trying to make this script read the text from this Microsoft console app called "dhcploc.exe"

(it searches for DHCP servers running on your network)

My current conclusion is, that there are just some programs that, alhough they output to the console window

you cannot send text/recieve text via StdinWrite/StdoutRead

What dhcploc does, when your press d is it sends a dhcp request to your network,

it then displays any dhcp servers running on your network...

so in my code i am running it, trying to send d, then read the reply

(please don't suggest i just use send(), that isn't an option here)

The code i currently have is as follows:

DirCreate ("tools");just incase
FileInstall ("dhcploc.exe",@ScriptDir&"\tools\dhcploc.exe")
ProcessClose ("dhcploc.exe")
$dhcploc = Run(@ScriptDir&"\tools\dhcploc.exe "&@ComputerName ,"",@SW_SHOW,9) 
 Sleep (500)
 
 $data = ""
 StdinWrite($dhcploc, "d"&@CRLF)
 StdinWrite ($dhcploc,"")

 While $dhcploc
    $tmp =  StdoutRead($dhcploc)
    $data &= $tmp
    ConsoleWrite ($tmp)
    Sleep (25)
WEnd

Thanks for taking the time to help :P

Instead of

StdinWrite ($dhcploc,"")

try

StdinWrite ($dhcploc)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi,

With the code below i can recieving the responce (stdoutread) but i am having to manually send d and q,

so the stdinwrite command isn't linking up for some reason :P

DirCreate ("tools")
FileInstall ("dhcploc.exe",@ScriptDir&"\tools\dhcploc.exe")
ProcessClose ("dhcploc.exe")
$dhcploc = Run(@ScriptDir&"\tools\dhcploc.exe "&@ComputerName ,"",@SW_SHOW,9) 
$data = ""
StdinWrite($dhcploc, "d")
StdinWrite($dhcploc, "q")
StdinWrite($dhcploc)


;10 second timeout
for $i = 1 to 10
    if not ProcessExists ("dhcploc.exe") then ExitLoop
    Sleep (1000)
next
ProcessClose ("dhcploc.exe")

While 1
    $tmp =  StdoutRead($dhcploc)
    if @error then ExitLoop
    $data &= $tmp
    ConsoleWrite ($tmp)
    Sleep (25)
WEnd

i have also tried control send but that didn't work either :(

Edited by boomingranny

Share this post


Link to post
Share on other sites

With the code below i can recieving the responce (stdoutread) but i am having to manually send d and q,

so the stdinwrite command isn't linking up for some reason :(

StdinWrite($dhcploc, "d")
StdinWrite($dhcploc, "q")
StdinWrite($dhcploc)

i have also tried control send but that didn't work either :idea:

StdInWrite() will not input anything to a command line shell. You can't automate a "DOS Box" this way with AutoIt.

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


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
Sign in to follow this  
Followers 0