Sign in to follow this  
Followers 0
Dev

Return From A Cmd-line To Autoit?

7 posts in this topic

#1 ·  Posted (edited)

Okay, lets say I need a line to get amount of MS returned from this Batchline:

Ping 127.0.0.1

Anyone knows how the AutoIt-code would look like? (or someone who can tip me if it exists in the helpfile). :whistle:

Thanks.

oops! Next to forgot -> :iamstupid:

Ps. Maybe its time to start the "Dev's n00by Questions"-topic? hehe Ds.

Edited by Dev

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Okay... but if i need to check if i have an established (right spelled?) connection with Netstat -n, and i dont want it to return more than the adress.

If we say, that I make a function, CheckAddresViaPort($port), and if $port is 456, the function should return the ip adress connected to port 456, not the rest you get if you type "netstat -n | find "456" in CMDwin. Grr... I hate to be a n00b :postal:

:iamstupid:

EDIT:

Woho! At least the board says im not a Newbie anymore *points under his picture* :whistle:

Edited by Dev

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Don't worry ... we have all been there at some point in time... :whistle:

what about something like this?

RunWait(@comspec & " /c netstat -n >" & @tempdir &"\netstats.tmp","",@sw_hide)
$file = FileOpen(@tempdir &"\netstat.tmp", 0)
; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    if StringInstr($line,":456") > 0 then msgbox(0,'found port 456' , $line)
Wend
FileClose($file)
Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Okay, Ill try it out, thanks for help :whistle:

EDIT: Tested

I dont get it to work, it allways generates the error "Cannot open file.", I dont know why (Ive changed port to a port I know a program is using).

Hope i dont need this soon --> :iamstupid:

Edited by Dev

Share this post


Link to post
Share on other sites

well thats because i made a typo..... :whistle:

First line says : \netstats.tmp

and fileopen: \netstat.tmp

Change the first line to:

RunWait(@comspec & " /c netstat -n >" & @tempdir &"\netstat.tmp","",@sw_hide)

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I think it works... at least it doesnt generate the error anymore. Thanks for help.

:iamstupid:

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