Interacting with windows command prompt via sensetalk

Hello

What I'm try to do is dynamically interact with the windows command prompt via sensetalk

I open the command prompt like this:
open process ("cmd")

Which seems to open fine, however when I try to read from it eggplant freezes

I have attempted these
read from process ("cmd") until end
read from process ("cmd") until eof

Both of which cause eggplant to freeze

I also tried this:
repeat forever
read from process "cmd" until return
if it is empty then exit repeat
put it
end repeat

Which spits out a line or two and then freezes

So I'm wondering how to do this properly

Also a second related question

Trying to pass cmd some parameters
tried this:
open process ("cmd") with options "/k <prog> <prog>"

it opened cmd but as far as I can tell didn't give it the command line parameters - what would be the proper syntax?

Thanks for any help

Comments

  • EggplantMattEggplantMatt ForumAdmin admin
    edited May 2018
    What's happening with the read is that the cmd process just isn't returning anything at all -- the read is getting stuck like with a null pointer. Once you read past the DOS prompt, there's just nothing there. We've come up with a workaround which involves just reading to the next occurrence of the prompt. To facilitate that, you need to start by sending a command to set the prompt to something that is easy to recognize; I chose "+>", but you can set it to be almost anything (see http://www.chami.com/tips/windows/020497W.html). I then wrote a function that I could just pass the command to run to in order to eliminate all the redundant code for reading and writing.
    global prompt
    set prompt to return & "+>"
    open process "cmd"
    put runCommand "PROMPT +$g"
    put runCommand "chdir C:\Users\support\"
    I hope you're able to make this work for you.
  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    For your second question, the options need to be a property list, with specific properties such as "directory" and "parameters". To pass parameters the correct syntax would be:
    open process "cmd" with options (parameters:("/k", "<prog>", "<prog>"))
    
Sign In or Register to comment.