Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Expect.pm and multiline commands

by cbrandtbuffalo (Deacon)
on Sep 28, 2006 at 09:28 UTC ( [id://575348]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

cbrandtbuffalo has asked for the wisdom of the Perl Monks concerning the following question:

In a typical unix shell, you can type a multiline command using \, that is:
shell>some -really -long -command 'string\ more string stuff'
I'm trying to build a test using Test::Expect, but I'm finding it hard to duplicate the above.

I tried a few variations and
expect_send(qq{some -command 'string stuff\\ \cM more on next line'}, +"Testing...");
seems to send the right stuff, escaping and sending a '\', then a newline. But I think Expect.pm is getting confused because it seems to treat the second part of the command as the expected output.

Is there a standard way to do this? Who's getting confused, Test::Expect, Expect::Simple, or Expect.pm?

Update:One other question: even if I get this working, will this test only work in some shells? That is, if I wanted it to be multi-platform, would I need multiple versions of the test?

Update:Modified example to show that the newline is inside a quoted string.

Thanks for any suggestions.

Replies are listed 'Best First'.
Re: Expect.pm and multiline commands
by Tomte (Priest) on Sep 28, 2006 at 09:48 UTC

    IIRC

    shell>some -really -long -command \ -with -many -options

    is actualy one line - the newline character is consumed and not part of the executed command.

    compare

    tomte@librics-tomte ~ $ echo "test eins" test eins
    to
    tomte@librics-tomte ~ $ echo "test\ eins" testeins

    regards,
    tomte


    An intellectual is someone whose mind watches itself.
    -- Albert Camus

      I should clarify my example because the case I'm trying to test actually matches your example. That is, I want to test a string passed to an option and the string should pass along the new line.

      I think your example may have answered my question about different shells. I use tcsh and I get:
      >echo "test\ ? stuff" test stuff >echo "test Unmatched ".

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://575348]
Approved by Hue-Bond
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.