Title: Glacier
I am developing the text file browser for the file of size > 100MB. "less" Unix command is pager for doing the same . I am developing the GUI interface for the same.
 
I am using the Expect/ TCL/ TK to build the GUI for the unix command "less". In "less", 'f' key forwards the one window. User need to hit the 'f' key continuously to scroll window by window.
 
In my program, when user click say 'Function key F1' , i need continuous scrolling window by window till usser press any other key. For this i wrote expect wrapper for "less" program as follows:
 
't' is the file of size 150 MB.
 
#!/usr/local/bin/expect -f
 
set timeout 2
set prompt "(%|#|\\$) $"                ;# default prompt
log_user 1
catch {set prompt $env(EXPECT_PROMPT)}
 
eval spawn less t
interact {
        "/" {send "/REPT\r"}
        "g" {send "g\r"}
        "q" {exit}
        "t" {
                send "f\r"
                send_user "panakj"
                sleep 2;
                send "f\r"
                send_user "panakj"
                sleep 2;
                send "f\r"
                send_user "panakj"
        }
        }
expect_user {
-re "g" {
                send_user "End of the Program"
        }
 
}
 
In above program , when user press key 't' then user see pankajpankajpankaj onscreen and then screen scrolls three times. I need first it scrolls, print pankaj,then again it scrolls and then print pankaj and so on. I am not able to figure out where is the problem. Is it the problem with the buffer ? not understanding why it is buffering the commands sent to spawned process and then executing them all at once ???
 
Can anyone know about it ??
 
Thanks in advance,
 

Pankaj

Reply via email to