Expect matching angled bracket prompt

Posted by jastorino on 2015-07-10 16:22
Forums: Expect discussion | OS: Windows 7


I need some help in understanding something about an expect script I am working on. I actually found a way to make what I want work, but I am not sure exactly what it works, and was hoping somebody could enlighten me.

Basically, I have an ActiveTCL/Expect script that does the following:

- spawns plink to SSH into a box
- once logged into the box, I run a program that returns a different prompt. The prompt that gets returned is simply the right angle bracket. It looks like this: >

Here is the problem I am facing - In my expect script, when I run the program that returns that right angle bracket prompt, I want to detect that so I can have the script respond by running a command. If I do expect ">" this doesn't work. The > character is never matched and eventually it times out.

On a hunch, I tried expect "\>" thinking that maybe > was a special character that needed escaped, and that works every single time. The problem I have, is I don't know WHY it works! I can't find anything that says angled brackets need escaped. Without the \ preceeding the angled bracket, it just hangs there

Any help would be greatly appreciated!