Jump to content
Sign in to follow this  
RogerRabbitsClone

send commands to cmd

Recommended Posts

RogerRabbitsClone

hello autoiters,

so heres my goal. i want to get ip address from the computer running this scritp and have it sent to my email. heres what i have so far.

this is the getting the info part:

Func ipconfig($lookfor = "DNS Servers")
    $cmd = Run(@Comspec & " /c ipconfig /all", "" , @SW_HIDE, 2+4)
    $Result = ""
    While 1
        $line = StdoutRead($cmd)
        If @error Then Return "Error"
        if StringInStr($line,$lookfor) then ExitLoop
    WEnd
    $Data = StringSplit(StringStripWS($line,7),$lookfor,1)
    $Data = StringSplit($Data[2],":",1)
    $Data = StringStripWS($Data[2],7)
    ConsoleWrite (@CR & $lookfor & "=" &$Data)
    Return $Data
endfunc
(i didnt write this, i got it from the forums)

this is the sending to email part:

ShellExecute ("cmd")
send ("telnet")
send ("{enter}")
sleep (300)
send ("open gmail-smtp-in.l.google.com 25")
send ("{enter}")
sleep(300)
send ("ehlo")
send ("{enter}")
sleep (300)
send ("MAIL FROM:<DNSinfo@DNSinfo.com>")
send ("{enter}")
sleep (300)
send ("RCPT TO:<myemail@gmail.com>")
send ("{enter}")
sleep (1000)
send ("DATA")
send ("{enter}")

i know using send is extremely buggy and i would rather do it the correct way, but im having trouble figuring out what the correct way would be.. should i be doing something like:

run ("/c telnet gmail-smtp-in.l.google.com 25")
consolewrite ("ehlo MAIL FROM:<DNSinfo@DNSinfo.com>")

what exactly is the correct way to send commands to cmd?

or should i just write a batch file and use fileinstall?

thanks


<--a good way to start you day

Share this post


Link to post
Share on other sites
KaFu
RogerRabbitsClone

ok...im having trouble understanding this. please bear with me,

so if i wanted to open cmd, and send it commands, i would do it like this?

$foo = Run(@ComSpec & " command1 && command2 && command3 && Exit", 'c:\', $STDOUT_CHILD)
$line = ""
While 1
    $line &= StdoutRead($foo)
    If @error Then ExitLoop
Wend
MsgBox(0,"","Finished" & @crlf & @crlf & @crlf & $line)

im having a hard time following this, i want to blame it on being up since 4am, but its probably just ignorance.


<--a good way to start you day

Share this post


Link to post
Share on other sites
PsaltyDS

Uhmm... how about just:

$Data = @IPAddress1

;)

Edit: I note the function you found pulls the DNS address by default, but you did say you wanted the IP.

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.