On 04/03/2013 08:55 PM, [email protected] wrote:
> Hi!
>>>> We find that sometimes "spawn /bin/su -l $USER1 -c whoami"
>>>> may return two lines:
>>>> "Attempting to create directory /home/su_usr2/perl5"
>>>> "su_usr2"
>>>> So the uncompleted "su_usr2" string match the first line,
>>>> but we expect to match the second line here.
>>>> So, fix it to match "su_usr2\r" instead.
>>>>
>>>> Reported-by: DAN LI <[email protected]>
>>>> Signed-off-by: Wanlong Gao <[email protected]>
>>>
>>> Looks good. What about making it even more strict with "^$USER\r"?
>>
>> I'm afraid that "^" is not supported.
>
> I've looked in the expect docs and the syntax for regular expressions
> should be '-re "^$USER\r"' (beware not tested).
I tested this and saw that it can't work, because the buffer of expect
is not line oriented, the "^" and "$" can't work well at most time.
Thanks,
Wanlong Gao
>
>>>
>>>> expect {
>>>> - "$USER1" { set i_am_correct 1 }
>>>> + "$USER1\r" { set i_am_correct 1 }
>>>> }
>>>> }
>>>> }
>>>
>>
>
------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list