Expect.pm

From: Mike (mikee_at_mikee.ath.cx)
Date: 11/20/03

  • Next message: Big and Blue: "Re: Retrieving dynamic web content"
    Date: Thu, 20 Nov 2003 22:20:44 -0000
    
    

    I'm having a problem in my code where I do an $exp->send($command);
    and the next line is an $exp->expect(undef, '-re', $prompt), but the
    code continues on without waiting. Anyone have an idea what my
    problem is?

    The commands are sent and executed, but the command before the 'rm'
    is not waited for. The script continues through to the exit.

    Mike

        # chmod the file
        if($opt_s) {
            $exp->send("chmod 744 /tmp/$bn\n");
            unless($exp->expect(30, '-re', $prompt)) {
                warn "timeout waiting for command to return";
            }

            # is the file there with the right permissions?
            $exp->send("ls -l /tmp/$bn\n");
            unless($exp->expect(30, '-re', $prompt)) {
                warn "timeout waiting for command to return";
            }

            # execute the file, wait until the command finishes
            $exp->send("/tmp/$bn $opt_i\n");
            unless($exp->expect(undef, '-re', $prompt)) {
                warn "timeout waiting for command to return";
            }
            $exp->send("rm -f /tmp/$bn\n");
        } else {
            # execute the command
            $exp->send("$opt_c\n");
            unless($exp->expect(60, '-re', $shellprompt)) {
                warn "timeout waiting for command to return";
            }
        }

        # exit
        $exp->send("exit\n");
        unless($exp->expect(10, 'onnection closed')) {
            warn "timeout waiting for command to return";
            $exp->hard_close();
        }
        $exp->soft_close();


  • Next message: Big and Blue: "Re: Retrieving dynamic web content"

    Relevant Pages

    • Re: Dropping DTR to access command mode during ppp session
      ... Then at the root prompt, ... Type your AT commands, and then hit ~. ... >According to the modem manual, dropping DTR will put the modem into ... Here's what I worry about. ...
      (freebsd-questions)
    • Re: Process Idle Time
      ... I basically want to know if the prompt is busy in any way. ... >> file in turn invokes several executables. ... it depends on what sorts of commands are used in the BAT or CMD file. ...
      (microsoft.public.win32.programmer.kernel)
    • [opensuse] Help installing openSUSE 10.2
      ... of the boot commands identified as runlevel 3. ... On boot screen use Other Options and enter 3 and press Enter to ... boot into runlevel 3, which is text mode with network. ... If computer gives you text mode login prompt enter user name, ...
      (SuSE)
    • Re: [opensuse] Konsole problems
      ... Most likely there's a problem with your PS1 string. ... the prompt string that do not yield visible characters must be ... and subsequently send incorrect positioning commands. ... In my shell, it's a shell procedure ...
      (SuSE)
    • Re: Run line problems
      ... Deleting the .coms re-enabled my commands. ... MS-MVP Windows Shell/User ... Open a command prompt, for you... ... Scroll down to PATHEXT ...
      (microsoft.public.windowsxp.help_and_support)