Hi, experts,
I wonder if anyone can help me up with this. Has been googling and reading several books but still come to no idea how this can be done. Well, it's like this. I have a bundle of codes developed in Perl. I need to do something like this:
1. perl script run using spawn
2. in between, there'll be messages print out to terminal, but I want to capture these messages into a variable (I don't want it to appear in the terminal).
3. A default selection will be sent to perl script.
4. Process 2-3 will continue until there's no more prompt to the terminal.
So far, I am only able to trap the first message and the perl script would not proceed to the next prompt. Here's my script:
#!/usr/bin/tcl -f
package require Expect
spawn myscript
log_user 0
expect "\r"
set savedoutput $expect_out(buffer)
# puts $savedoutput
expect "name?"
send -- "1\r"
--> don't know how to proceed from here
exit 0
# content of myscript:
#!/usr/local/bin/perl
#print "hello, what's your name?\n";
#print "1. Sally\n2. Caroline\n3. Anthony\n";
#$name = <STDIN>;
#print "Now, tell me your age:\n";
#print "1. 10-19\n2. 20-29\n3. 30-39\n";
#$age = <STDIN>;
Any idea of how this can me done?
Regards,
dniz