我有一個代碼(1)應該在另一個代碼(它是僞bash)中執行測試。此代碼(1)是使用「期望」寫入「用戶模擬」的。系統命令rm不能在expect程序中工作
問題是當代碼(1)執行一個系統(在這種情況下,系統「rm totoExpect.txt titiExpect.txt」)時,它只是沒有找到titiExpected.txt,但在那裏!
這兩個文件之間沒有什麼不同,即使權限是相同的,我不能認爲在一個不起作用的原因。
下面是代碼(1),其中所述問題提出的部分:
# 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"
}
和錯誤消息:
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 "(\[\]+)\..."
(file "./testshell.expect" line 99)
make: ** [test] Erro 1
其中 「RM:NAO FOIpossível卸妝」 titiExpect.txt 「:Arquivo oudiretórionãoencontrado」 表示「rm:無法刪除」titiExpect.txt「:找不到文件或目錄」(對不起...)
and this是ls -l命令只是錯誤消息後(所以titiExpect.txt不應該在那裏):
-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
最糟糕的問題是這樣的代碼是不應該被修改,但它在我看來,這是程序故障這失敗了。 (其實評論線解決問題..)
任何想法?
'totoExpect的文件權限。txt'和'titiExpect.txt'文件? – askmish
這兩個rwx爲用戶 – FernandoP