Jump to content

Recommended Posts

Posted

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 

Posted

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)

  • Developers
Posted (edited)

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

Posted (edited)

@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
  • Developers
Posted

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

  • Developers
Posted

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

Posted

Keep in mind @hani-dev something like this can be done much easier in a batch script:

set /P id=Enter site to ping: 
ping %id%
pause

If this is run inside a .bat file it does what you're trying to do in AutoIt.

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Posted

Haha that's true, I suppose we wouldn't have a lot of our fancy UDFs if we didn't try to do every possible thing in AutoIt :P

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Posted

@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 !!

 

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.
×
×
  • Create New...