I need to write a program that runs an external program and the user needs 
to interact with that external program.  So I know I can do something like 
this:


func main() {
cmd := exec.Command("/usr/local/bin/interactiveApp")
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()

What I need to be able to do is look at what the user is typing as the user 
can make some errors that would be unfortunate, So what I want to do is 
look at what the user typed and tell them that isn't possible. If the 
command is good send it.

User: "self destruct in 10 minutes"
MyApp: "sorry you can't do that."

This is very similar to what you can do with Don Libes's Expect interact 
statement which works like a switch statement, if a match is found, it runs 
that instead of what the user typed. 

spawn "/usr/local/bin/interactiveApp"
...stuff...

interact {
"self destruct" {
send_user "Sorry you can't run that"
send "start over"
}
}
 
So if the user types "self destruct" the program will send a message to the 
user, and then send 'start over' to the interactiveApp.    I've looked 
around and I've not seen anything that can reliably read from what the user 
types in, evaluate it,  and pass it to the program that is launched by exec.

I didn't write the app we're  running, and the guy that wrote it is not 
able to support it any longer. I"d write it in expect but expect uses TCL 
which is very very slow, and there are other aspects to Go that I really 
need in other areas of the program.

Thanks! 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/65aab0d3-0d74-425e-a4fe-c26c39b98169%40googlegroups.com.

Reply via email to