Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

StdoutToVar


  • Please log in to reply
121 replies to this topic
majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006

However, due to an apparent lack of interest in CMDret, although it is still being developed, I have decided not to spend the time posting any updates for it.

Argh, don't be ridiculous. When lack of interest had anything to do with the quolity of the thing? This is great function and you should update it.

CMDret was originally provided as a function to allow people at the forum an opportunity to participate in development in hopes that the result would inspire Chris to add this functionality (possibly with similar syntax and functionality of the version(s) posted) as a built-in command/function in AutoHotkey.

I don't see why function can't be equaly powerful.
Posted Image

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

Sean, It looks like your version is coming along nicely :) . I would have preferred if it the functionality was produced as a single function instead of several functions that rely on each other but some people tend to prefer things broken apart in small pieces. It's all good :) .

Thanks and I know what you mean. Personally, I also prefer having it in a single procedural entity and found it myself easier to follow. Contrary to my expectation, however, looks like many users feel it complicated in that way, so I tended to write in a function form and expose only necessary steps.

One of the main reasons for CMDret creating a hidden console window was for compatibility for a few specific applications and for creating workarounds for 16 bit applications (unreleased versions). This difference can be made in either version by modifying one line of code though.

I see. I thought you might have a reason about that.

Erittaf
  • Guests
  • Last active:
  • Joined: --
regarding StdoutToVar.ahk:

First, Where does this actually access cmd.exe?

Secondly, would this be adaptable to work with telnet.exe?

I am trying to get a responsive from of telnet (i.e. to login and run certain commands dependant on what information is currently in the telnet window, hidden or not)

I have tried to use this to access telnet but it does not return anything at all.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

First, Where does this actually access cmd.exe?

When it calls CreateProcess(), but without creating the console window, so you may not notice it.

Secondly, would this be adaptable to work with telnet.exe?

telnet.exe is an interactive app, i.e., needs an interaction with the user, so I don't think this script is usable with it. The same with netsh.exe.

SecurityAnalysis
  • Guests
  • Last active:
  • Joined: --
What does sWork do? I see it is empty in both examples. I'm just curious what it does. Thanks for creating such a great script for us other people on the forum.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

What does sWork do?

It'll set the Current/Working directory, which corresponds to AHK's A_WorkingDir.

SecurityAnalysis
  • Guests
  • Last active:
  • Joined: --
Thanks

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
At last I updated StdoutToVar.ahk and StdoutWithCOM.ahk and combined into one.
They aren't tested thoroughly as I uses console apps less and less thanks to AHK, so please post here if find a bug. Thanks.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
The script is simplified further. Now, I think/hope it's really easy to use.
sCmd := "ipconfig /all"
;bStream := ""
;sDir := ""
;sInput := ""

MsgBox % StdoutToVar_CreateProcess(sCmd, bStream, sDir, sInput)	; StdoutToVar_CreateProcessCOM(sCmd, bStream, sDir, sInput)


AHKnow
  • Members
  • 121 posts
  • Last active: May 17 2009 09:11 PM
  • Joined: 03 Jul 2004
Both this and CMDret are great. Hats off to both authors.

As far as the interest issues go, I think that is due to needing more examples of how it works. If you focus just on StdoutToVar.ahk and CMDret , than possibly more novice or casual users may get lost with how you created the script, DllCall talk, etc...

From a user perspective, maybe when people see more of the possibilities and how to use it that it would generate more interest.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

From a user perspective, maybe when people see more of the possibilities and how to use it that it would generate more interest.

I thought there was little to tell more about it, quite self-evident. I may be wrong. Here are a few more examples.

; StdoutToVar_CreateProcess(sCmd, bStream = False, sDir = "", sInput = "") ; The function definition
MsgBox % sOutput := StdoutToVar_CreateProcess("ipconfig.exe /all")
MsgBox % sOutput := StdoutToVar_CreateProcess("ping.exe www.autohotkey.com", True) ; with Streaming On
MsgBox % sOutput := StdoutToVar_CreateProcess("cmd.exe /c dir /a /o", "", A_WinDir) ; with Working Directory
MsgBox % sOutput := StdoutToVar_CreateProcess("sort.exe", "", "", "abc`r`nefg`r`nhijk`r`n0123`r`nghjki`r`ndflgkhu`r`n") ; with Stdin string


User2001
  • Guests
  • Last active:
  • Joined: --
Hi,

is it possible to use this function with tools like telnet? just to get alle the text telnets writing.
A script like this:
- starting telnet
- getting text by your function (how could this work?)
- sending command to telnet
- getting text again

and so on. I hope its no big deal?

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

is it possible to use this function with tools like telnet?

There already is the same question a few posts above.

User2001
  • Guests
  • Last active:
  • Joined: --
Yes, i already noticed that. But you said its not possible, because its need interaction with the user. But wheres the problem with interaction? I just get a problem getting the telnet text again and again.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

I just get a problem getting the telnet text again and again.

In this case you may use it. But, the problem is: how you're gonna terminate the telnet.exe gracefully? There is no way except using AHK's built-in function "Process, Close" or directly TerminateProcess API (which is easier one in this case). They (actually it) are not graceful exit, you may lose data.