in reply to Need help on expect

Disclaimer: Without having the actual program to interact with, the following is only based on a simplified test. Also, I assume that the program's prompts are as shown in the regular expressions (with the exception of \s+ instead of \\s+).

Another problem is that the second "Enter pack name" regex, qr/Enter pack name \(or q\) \[q\]: \(q\)\s+/, will never match, because the first "Enter pack name" regex, qr/Enter pack name \(or q\) \[q\]:\s+/ will always match first. So one possible solution is to move the second regex before the first.

Or, you could remove the second "Enter pack name" regex, and apply either of the two solutions given above (1, 2), they do seem to work under the assumptions given above.

Replies are listed 'Best First'.
Re^2: Need help on expect
by toaravind (Initiate) on Feb 22, 2015 at 04:57 UTC
    Thanks for your replies, I somehow not able to search the below

    Can not install pack when NetBackup daemons are running.

    "<TAB space>" Do you want to kill all NetBackup daemons? y,n (y)

    using the below
    [ qr/Do you want to kill all NetBackup daemons\? \[y,n\] \(y\)\s+/ => +sub { $exp->send("\r"); exp_continue; } ],
    Please let me know if I am searching it wrong.

      Without knowing the output of the program you're working with, this is just a guess, but perhaps your regex doesn't need to be so specific, and something like qr/Do you want to kill all NetBackup daemons\?/ might be enough?

        Thanks all, it has been fixed and my perl script is working as expected.