Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Look.</p> <pre><code># test 5 proc t5 {} { send "ls &gt; totoExpect.txt\r" send "cat &lt; totoExpect.txt | wc -l &gt; titiExpect.txt\r" send "cat titiExpect.txt\r" expect -re "(0|1|2|3|4|5|6|7|8|9)+.*&gt;" { ok 5; } default { abort 5 } system "rm totoExpect.txt titiExpect.txt" } </code></pre> <p>The first <code>send</code> crates a file named <code>totoExpect.txt\r</code>.</p> <p>The second <code>send</code> generates a file named <code>titiExpect.txt\r</code>. The <code>cat</code> part actually fails, because there is no file <code>totoExpect.txt</code>, but since the command is part of a pipe, and not the last command in said pipe, expect will not catch that as an error. (All you'll see is that the <code>titiExpect.txt\r</code> file will be empty.)</p> <p>The <code>\r</code> above is the CR character, and probably the reason you have missed it. In Linux, it is perfectly allowed character in file names (as only <code>/</code> and <code>\0</code> are forbidden). Just remove it from your test and you'll find it works fine.</p> <p>Or, if you insist on keeping it, then keep it consistently:</p> <pre><code># test 5 proc t5 {} { send "ls &gt; totoExpect.txt\r" send "cat &lt; totoExpect.txt\r | wc -l &gt; titiExpect.txt\r" send "cat titiExpect.txt\r" expect -re "(0|1|2|3|4|5|6|7|8|9)+.*&gt;" { ok 5; } default { abort 5 } system "rm totoExpect.txt\r titiExpect.txt\r" } </code></pre> <p>Finally, when removing files, it is recommended to use the <code>-f</code> flag, so <code>rm</code> does not complain if one of the files happens to not exist.</p> <p>My suggestion is to rewrite that test as</p> <pre><code># test 5 proc t5 {} { send "ls &gt; totoExpect.txt" send "cat &lt; totoExpect.txt | wc -l &gt; titiExpect.txt" send "cat titiExpect.txt" expect -re "(0|1|2|3|4|5|6|7|8|9)+.*&gt;" { ok 5; } default { abort 5 } system "rm -f totoExpect.txt titiExpect.txt" } </code></pre> <p>eradicating those erratic <code>\r</code>s.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload