Source language: Translate to:

How to use specific DosCommands ?

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

How to use specific DosCommands ?

Postby sammuelsan » Sat May 07, 2005 1:19 pm

Hello NeoSofters,

I'd like some help on basic dos commands, like ping -t, or ipconfig/all, or some other useful commands for network troubleshooting.

Run "C:\WINDOWS\SYSTEM32\ping.exe" "[TextEntry1]" "Normal"
(This one is working fine, but I would like to add this; >C:\Temp\ping.txt)
To create a text file and to display it with the same function or with others lines, just by pressing a button.

Like ;
Run "C:\WINDOWS\SYSTEM32\ping.exe" "[TextEntry1]" " >C:\Temp\ping.txt"
TextWindow "Requete ping" "0" "0" "0" "0" "C:\Temp\ping.txt" "Wordwrap"

But Its not working at all...

And a command like this;
DOSCommand "C:\WINDOWS\SYSTEM32\net.exe" "use [ListBox1] \\[TextEntry3] /user:administrator password" "Normal"

-List box from a: to z:
-TextEntry3 : the network drive like \\server\share

Do you have an idea about how to proceed ???

Thx
User avatar
sammuelsan
 
Posts: 2
Joined: Sat May 07, 2005 11:23 am
Location: Montreal

Postby Sam Cox » Sat May 07, 2005 8:30 pm

Hi sammuelsan,

Welcome to the Forum.

The ping program itself knows nothing about IO redirection. The reason redirection works from the command line is because the command interpreter (cmd in the case of NT and 2K) handles that kind of stuff.

We can invoke the command interpreter to handle the IO redirection, and then run the ping program by first writing and then calling a one-off batch file. The following should come close to working for you:
Code: Select all
SetVar "[Batch]" "c:\temp\ping.bat"
SetVar "[Ping]" "c:\winnt\system32\ping.exe"
SetVar "[Out]" "c:\temp\ping.txt"
FileWrite "[Batch]" "All" "[Ping] [TextEntry1] >[Out]|exit"
Run "[Batch]" "" "RunOnce+Hidden" "" ""
TextWindow "PING" "-1" "-1" "-1" "-1" "[Out]" "Wordwrap"

Note: If, in the FileWrite command, you replace the variable [Batch] with the literal "c:\temp\ping.bat", you must put a "!" (bang) as the first character. The "!" tells Neobook to take the string literally. That is, you must write
Code: Select all
FileWrite "!c:\temp\ping.bat" ...
instead of
Code: Select all
FileWrite "c:\temp\ping.bat" ...
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Its an interesting function...

Postby sammuelsan » Sat May 07, 2005 9:27 pm

Hello Sam,

Thanks for having replied so quickly.

The function to create a folder and *.bat has worked perfectly, but the ping function has not worked...

Its returning and empty folder ping.txt :cry: ...But its an interesting function, I've never program anything, but I like the way it works... :idea:

SetVar "[Batch]" "!c:\temp\ping.bat"
SetVar "[Ping]" "c:\winnt\system32\ping.exe"
SetVar "[Out]" "c:\temp\ping.txt"
FileWrite "[Batch]" "All" "[Ping] [TextEntry1] >[Out]|exit"
Run "[Batch]" "" "RunOnce+Hidden"
TextWindow "PING" "-1" "-1" "-1" "-1" "[Out]" "Wordwrap"


Why do we need to call FileWrite "[Batch]" "All" ???

Do you see what is not good on the code ?

Thanks Sam
User avatar
sammuelsan
 
Posts: 2
Joined: Sat May 07, 2005 11:23 am
Location: Montreal

Postby Sam Cox » Sat May 07, 2005 9:44 pm

Try adding a delay between running the batch file and opening the text window, or change "RunOnce" to "RunOnce+Wait" in the Run command.
Code: Select all
SetVar "[Batch]" "[tempdir]ping.bat"
SetVar "[Ping]" "c:\winnt\system32\ping.exe"
SetVar "[Out]" "[tempdir]ping.txt"
FileWrite "[Batch]" "All" "[Ping] [TextEntry1] >[Out]|exit"
Run "[Batch]" "" "RunOnce"
Delay "5000"
TextWindow "PING" "-1" "-1" "-1" "-1" "[Out]" "Wordwrap"

The FileWrite command creates the batch file we execute with the Run command. The "all" in Filewrite "[batch]" "all" "..." has the effect of replacing the entire file if the file already exists.

Notice that I changed "c:\temp\" to "[tempdir]" which is a more Neobook-like way of specifying the a temp directory.
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby Neosoft Support » Tue May 10, 2005 10:50 am

You might also try adding the "wait" option to your Run action so that NeoBook will pause until the program has completed it's task. I'm not sure how well wait works with batch files, but it should work with the actual exe.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5603
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

More speeder ping

Postby gemlik » Tue May 10, 2005 1:20 pm

If you want to use more speeder ping, here it is:

http://www.naughter.com/download/ping.zip

Dont worry ! It's free. :)
gemlik
 
Posts: 8
Joined: Sat Apr 02, 2005 3:55 am
Location: Turkey

Re: More speeder ping

Postby aguilar955 » Wed Jul 06, 2011 4:47 am

gemlik wrote:If you want to use more speeder ping, here it is:

http://www.naughter.com/download/ping.zip

Dont worry ! It's free. :)


Thank you very much.

Code: Select all
ExtractFile "[Embedded]cping.exe" "[CurrentDir]cping.exe"
Run "cmd" "/c cping -n:5 [EntradaTexto2] > resultado.txt" "Wait+Hidden" "" ""
FileErase "[CurrentDir]cping.exe"
FileRead "[CurrentDir]resultado.txt" "All" "[EntradaTexto1]"

FileLen "[CurrentDir]resultado.txt" "[linea]"
Loop "1" "[linea]" "[cual]"
    FileRead "[CurrentDir]resultado.txt" "[cual]" "[contenido]"
    SearchStr "Failed" "[contenido]" "[encontrado]" ""
    If "[encontrado]" "<>" "0"
        StrLen "[contenido]" "[longitud]"
        SearchStr ":" "[contenido]" "[posicion]" ""
        StrDel "[contenido]" "1" "[posicion]+1" "[error]"
        SetVar "[error[cual]]" "[error]"
        SetVar "[ip[cual]]" ""
        SetVar "[rtt[cual]]" ""
    Else
        SetVar "[error[cual]]" ""
        SearchStr "replied" "[contenido]" "[posicion]" ""
        If "[posicion]" "<>" "0"
            SubStr "[contenido]" "1" "[posicion]-2" "[ip]"
            SetVar "[ip[cual]]" "[ip]"
        EndIf
        SearchStr ":" "[contenido]" "[posicion]" ""
        If "[posicion]" "<>" "0"
            StrLen "[contenido]" "[longitud]"
            SubStr "[contenido]" "[posicion]+1" "[longitud]-([posicion]+1)" "[rtt]"
            SetVar "[rtt[cual]]" "[rtt]"
        EndIf
    EndIf
EndLoop

FileErase "[CurrentDir]resultado.txt"


Salu2
aguilar955
 
Posts: 85
Joined: Sat Jan 17, 2009 10:50 am


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest