Advertisement
Guest User

Bipolar - Expect and Left Arrow key

a guest
Mar 29th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. $ od -c
  2. [Hit left arrow]
  3. ^[[D
  4. 0000000 033 [ D \n
  5. 0000004
  6.  
  7. $ od -c
  8. [Hit right arrow]
  9. ^[[C
  10. 0000000 033 [ C \n
  11. 000000
  12.  
  13. expect.test script:
  14. #!/usr/bin/expect -f
  15. spawn /bin/bash
  16. interact {
  17. "\033\[C" {exp_send "\033\[C";
  18. send_user "Right Arrow Pressed\n"} # Right Arrow
  19. "\033\[D" {exp_send "\033\[D";
  20. send_user "Left Arrow Pressed\n"} # Left Arrow
  21. }
  22.  
  23. Running the script:
  24. $ ./expect.test
  25. spawn /bin/bash
  26. $
  27. [Hit right arrow]
  28. Right Arrow Pressed
  29. [Hit left arrow... no output but the key does work and moves the cursor]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement