hani-dev

cmd read command from consolread

35 posts in this topic

#1 ·  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 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Hi @hani-dev:)

Do you want to develop an application compatible with MS-DOS or with Windows?

That should not be so difficult to do :)


Best regards.


Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

@FrancescoDiMuro for windows but work in dos  #pragma compile(Console, True)

but i dont know ho to do what i asked for in the first post 

Edited by hani-dev

Share this post


Link to post
Share on other sites

#5 ·  Posted

@Jos i already do that and i did not understand how to do that :(

 

Share this post


Link to post
Share on other sites

#7 ·  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)

Share this post


Link to post
Share on other sites

#8 ·  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

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

#9 ·  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

Share this post


Link to post
Share on other sites

#10 ·  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


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

#11 ·  Posted

yes @jos that what i need :) but i need it without gui i mean without inputbox i need to write it from cmd window 

Share this post


Link to post
Share on other sites

#12 ·  Posted

like this @Jos

Untitled.png (535×330)

Share this post


Link to post
Share on other sites

#13 ·  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

1 person likes this

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

#14 ·  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=

Share this post


Link to post
Share on other sites

#16 ·  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=

Share this post


Link to post
Share on other sites

#17 ·  Posted

@Jos u are the boss man <3 it's working thanx u very much <3 

Share this post


Link to post
Share on other sites

#18 ·  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 !!

 

Share this post


Link to post
Share on other sites

#19 ·  Posted

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


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

#20 ·  Posted

I think he purely wants it ran from inside SciTe, not a cmd window.

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