in reply to Re: Expect question
in thread Expect question

If you look at the debug dump, two spaces is what's coming back from the SFTP server:
expect(): handling param 'Password: '... expect(): exact match 'Password: '...
There are two spaces after : until the end of the quoted string. This is an exact copy/paste from my output. I started with no spaces, then I saw the dump and I added one space, it still didn't and I looked more carefully and noticed there were two spaces, but it still doesn't work.

Replies are listed 'Best First'.
Re^3: Expect question
by Crackers2 (Parson) on Oct 27, 2007 at 00:37 UTC

    I might be wrong of course, but it looks to me like that's just the parsing of the parameter you gave to the function, not what was received from the server.

    Could the problem have something to do with the "exact match" part? You can see it's trying to match against 'Connecting to <host_ip>...\r\nPassword: '

    So perhaps you need something like '.*Password: ' as a pattern? (assuming it takes regexes).

      I have replaced my "Password: " pattern with the entire Connecting to... blah blah string and that one is matched. The regexp does not work which seems weird. In this case it's easy to either use the entire string or even generate it before using it, so I can use the IP and a parameter, but it just doesn't feel right. Somehow I suspect I should be able to verify only the last part of a return... I can easily imagine servers that spit out a whole load of stuff before prompting you for an input and I just don't think we always need to search and match that entire speech... At least I know it's about tail matching now.
Re^3: Expect question
by jasonk (Parson) on Oct 29, 2007 at 19:21 UTC

    These two lines of debugging output both display your expect pattern as it is being built by Expect, meaning the text in those two lines is from your code, not from the server.


    We're not surrounded, we're in a target-rich environment!