Jump to content

cmd read command from consolread


Recommended Posts

hello there...

i need to write script run in MS DOS and when u run it it's ask u to write website like www.google.com and then when u hit enter i must got the result of :

ping www.google.com

i other word (ping) must be built in with my script 

sorry for bad english 

can we do that 

Link to comment
Share on other sites

  • Developers

Look at StdoutRead() and StderrRead() in the helpfile on how to read the IO stream of a CMD.

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 comment
Share on other sites

i found this code : 

#include <Constants.au3>



$DOS = Run(@ComSpec & " /c Ping www.google.com", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($DOS)
$Message = StdoutRead($DOS)

ConsoleWrite($Message)

what i need is to modify the code to ping any website ( read website from consoleread , consolewrite ) exapmle : 

$DOS = Run(@ComSpec & " /c Ping ($website provided manually), "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

Link to comment
Share on other sites

  • Developers

I am lost: Why change the command line? Are you seriously trying to run the AutoIt3 Function in a CMD prompt?
or do you want to use a variable which the script will prompt for?

Jos

Edited by 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 comment
Share on other sites

@Jos Let me try to clarify ... first of all my english is 2 bad ...

what i want to do is to run this script from cmd i add this to do it : 

#pragma compile(Console, True)

ok ... the next step when i want to execute my script from cmd i need it to ask me to write the website  (any website wrriten manually )and just hit enter to get this result :

Note : just write website without Ping 

Quote

Pinging www.google.com [172.217.17.68] with 32 bytes of data:
Reply from 172.217.17.68: bytes=32 time=114ms TTL=53
Reply from 172.217.17.68: bytes=32 time=107ms TTL=53
Reply from 172.217.17.68: bytes=32 time=111ms TTL=53
Reply from 172.217.17.68: bytes=32 time=109ms TTL=53

Ping statistics for 172.217.17.68:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 107ms, Maximum = 114ms, Average = 110ms

 

Edited by hani-dev
Link to comment
Share on other sites

  • Developers

Ok... so something like this?:

#pragma compile(Console, True)
#include <AutoItConstants.au3>
$web=InputBox("ping website","specify website to check")
if @error then Exit
$DOS = Run(@ComSpec & " /c Ping " & $web, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
while ProcessExists($DOS)
    $Message = StdoutRead($DOS)
    ConsoleWrite($Message)
WEnd
$Message = StdoutRead($DOS)
if $Message <> "" then ConsoleWrite($Message)

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 comment
Share on other sites

  • Developers

Something like this:

#pragma compile(Console, True)
#include <AutoItConstants.au3>
ConsoleWrite("Please enter website:")
$web = ""
While 1
    $web &= ConsoleRead()
    If StringInStr($web, @LF) Then ExitLoop
WEnd
ConsoleWrite("pinging:" & $web)
$DOS = Run(@ComSpec & " /c Ping " & $web, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
While ProcessExists($DOS)
    $Message = StdoutRead($DOS)
    ConsoleWrite($Message)
WEnd
$Message = StdoutRead($DOS)
If $Message <> "" Then ConsoleWrite($Message)

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 comment
Share on other sites

  • Developers
4 minutes ago, anthonyjr2 said:

can be done much easier in a batch script

Where is the fun in that??

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 comment
Share on other sites

@jos im soryy man it's now working outside the SCITElite 

when i open cmd windows and try to run my compiled .exe i got this 

Untitled.png

it's now writing anythink and not doing anythink it's just stuck on this screen !!

 

Link to comment
Share on other sites

  • Developers

Not sure what you mean. It is working fine when I compile the script and run it from a CMD prompt.
So what exactly is not working for you?

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 comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...