Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8833311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:44:59+00:00 2026-06-14T08:44:59+00:00

I have a code (1) that is supposed to execute test in another code

  • 0

I have a code (1) that is supposed to execute test in another code (its a pseudo-bash). This code (1) is wrote using the “expect” for the ‘user simulation’.

The problem is when this code (1) execute a system ( on this case, system “rm totoExpect.txt titiExpect.txt”) when its just doesnt find the titiExpected.txt, but is there!

There is nothing different between the two files, even the permissions are the same, i cant think in a reason that doesnt work.

Here is the part of the code (1) where the problem raises:

# test 5
proc t5 {} {
    send "ls > totoExpect.txt\r"
    send "cat < totoExpect.txt | wc -l > titiExpect.txt\r"
    send "cat titiExpect.txt\r"
    expect -re "(0|1|2|3|4|5|6|7|8|9)+.*>" { ok 5; } default { abort 5 }
    system "rm totoExpect.txt titiExpect.txt"
}

And the Error message:

ls > totoExpect.txt
out: totoExpect.txt
seq[0]: 'ls' 
-----3
ensishell>c
 ***** TEST 5 ok

rm: não foi possível remover "titiExpect.txt": Arquivo ou diretório não encontrado
child process exited abnormally
    while executing
"system "rm totoExpect.txt titiExpect.txt""
    (procedure "t5" line 6)
    invoked from within
"t5"
    ("eval" body line 1)
    invoked from within
"eval "t$t;" "
    ("foreach" body line 1)
    invoked from within
"foreach t {0 1 2 3 4 5 6 7} { eval "t$t;" } "
    invoked from within
"expect_user {
    -timeout 30 "auto\n" {
    puts "AUTO:\n";
    foreach t {0 1 2 3 4 5 6 7} { eval "t$t;" } 
    }
    -timeout 30 -re "(\[0123456789 \]+)\..."
    (file "./testshell.expect" line 99)
make: ** [test] Erro 1

Where “rm: não foi possível remover “titiExpect.txt”: Arquivo ou diretório não encontrado”
means “rm: it was not possible to remove “titiExpect.txt”: file or directory not found” (sorry about that…)

and this is the ls -l just after the error message (so titiExpect.txt shouldnt be there):

-rwxrwxr-x   1 fernando       fernando    273 Out 23 17:53 #Makefile#
-rwxrwxr-x   1 fernando       fernando   6238 Nov  5 21:18 #ensishell.c#
-rwxrwxr-x   1 fernando       fernando   1271 Out 24 20:30 #readcmd.h#
-rwxrwxr-x   1 fernando       fernando   3250 Nov  5 21:07 #testshell.expect#
-rwxrwxrwx   1 fernando       fernando    303 Out 24 20:21 Makefile
drwxrwxr-x   2 fernando       fernando   4096 Nov  4 19:06 SEPC shell
-rw-rw-r--   1 fernando       fernando 193453 Out 18 18:25 Sujet_shell.pdf
-rwxrwxr-x   1 fernando       fernando  25451 Nov  5 21:17 ensishell
-rwxrwxrwx   1 fernando       fernando   6238 Nov  5 20:32 ensishell.c
-rw-rw-r--   1 fernando       fernando  10664 Nov  5 21:17 ensishell.o
-rwxrwxr-x   1 fernando       fernando   7251 Nov  4 00:33 foo
-rw-rw-r--   1 fernando       fernando    173 Nov  4 00:33 foo.c
-rw-rw-r--   1 fernando       fernando     16 Nov  4 01:15 in.txt~
-rwxrwxrwx   1 fernando       fernando   6603 Out 23 00:37 readcmd.c
-rwxrwxrwx   1 fernando       fernando   1271 Out 23 01:24 readcmd.h
-rwxrwxrwx   1 fernando       fernando   1271 Out 23 00:37 readcmd.h~
-rw-rw-r--   1 fernando       fernando  11216 Nov  5 21:17 readcmd.o
-rwxrwxrwx   1 fernando       fernando   3250 Nov  5 20:41 testshell.expect
-rwx------   1 fernando       fernando   1263 Nov  5 12:43 toto.txt

The worst problem is this code is not supposed to be modified, but its seems to me that is the programs fault this fail. (in fact, commenting the line solve the problem..)

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:45:00+00:00Added an answer on June 14, 2026 at 8:45 am

    Look.

    # test 5
    proc t5 {} {
        send "ls > totoExpect.txt\r"
        send "cat < totoExpect.txt | wc -l > titiExpect.txt\r"
        send "cat titiExpect.txt\r"
        expect -re "(0|1|2|3|4|5|6|7|8|9)+.*>" { ok 5; } default { abort 5 }
        system "rm totoExpect.txt titiExpect.txt"
    }
    

    The first send crates a file named totoExpect.txt\r.

    The second send generates a file named titiExpect.txt\r. The cat part actually fails, because there is no file totoExpect.txt, 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 titiExpect.txt\r file will be empty.)

    The \r 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 / and \0 are forbidden). Just remove it from your test and you’ll find it works fine.

    Or, if you insist on keeping it, then keep it consistently:

    # test 5
    proc t5 {} {
        send "ls > totoExpect.txt\r"
        send "cat < totoExpect.txt\r | wc -l > titiExpect.txt\r"
        send "cat titiExpect.txt\r"
        expect -re "(0|1|2|3|4|5|6|7|8|9)+.*>" { ok 5; } default { abort 5 }
        system "rm totoExpect.txt\r titiExpect.txt\r"
    }
    

    Finally, when removing files, it is recommended to use the -f flag, so rm does not complain if one of the files happens to not exist.

    My suggestion is to rewrite that test as

    # test 5
    proc t5 {} {
        send "ls > totoExpect.txt"
        send "cat < totoExpect.txt | wc -l > titiExpect.txt"
        send "cat titiExpect.txt"
        expect -re "(0|1|2|3|4|5|6|7|8|9)+.*>" { ok 5; } default { abort 5 }
        system "rm -f totoExpect.txt titiExpect.txt"
    }
    

    eradicating those erratic \rs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have hit a mental wall. Basically, this code is supposed to execute and
I have this code that is supposed to load the attributes of an XML
I have some code that is supposed to return an NSString. Instead it is
I am new to the web development. I have a code that's supposed to
I have a piece of Python code that is supposed to open a new
I have a very simple bit of code that is supposed to capture the
The following code is supposed to find electors that do not have a postal
I have this code that suppose to place the marker by the latlng public
I have this javascript code below that uses jquery, it is suppoed to be
I have a big stored procedure that I run. At the end its supposed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.