Tcl 从expect脚本中的交互返回

Tcl 从expect脚本中的交互返回,tcl,expect,Tcl,Expect,我正在使用DAOMATCH,一个天文学程序来寻找图像之间的匹配,我正在尝试用EXPECT半自动化它 程序要求一些输入,如果失败,他会问我是否要保持转换。这就是为什么我想半自动化它:我想自动给他输入,但当“写这个转换”的问题出现时,我想控制程序。为此,我编写了(TCL初学者)这段代码 #!/usr/bin/expect -D set timeout 1 spawn "~/myDaophot/daophot4/daomatch" expect "*Master*" send "060326T03

我正在使用DAOMATCH,一个天文学程序来寻找图像之间的匹配,我正在尝试用EXPECT半自动化它

程序要求一些输入,如果失败,他会问我是否要保持转换。这就是为什么我想半自动化它:我想自动给他输入,但当“写这个转换”的问题出现时,我想控制程序。为此,我编写了(TCL初学者)这段代码

#!/usr/bin/expect -D

set timeout 1

spawn "~/myDaophot/daophot4/daomatch"
expect "*Master*"
send "060326T034700403_4.als\r"
expect "*Output*"
send "060326T002448794_2_4.mch\r"
expect "*input*" {send "060326T034700403_2.als\r"}
expect "*transformation*" {interact -o "y\r" {return}}
expect "*input*" {send "060326T034519602_4.als\r"}
expect "*transformation*" {interact -o "y\r" {return}}
expect "*input*" {send "060326T034519602_2.als\r"}
expect "*transformation*" {interact -o "y\r" {return}}
expect "*input*" {send "060326T002627552_4.als\r"}
expect "*transformation*" {interact -o "y\r" {return}}
expect "*input*" {send "060326T003255953_2.als\r"}
expect "*transformation*" {interact -o "y\r" {return}}
expect "*input*" {send "060326T003521749_2.als\r"}
#Question pops up here!!!
expect "*transformation*" {interact -o "y\r" {return}}
#-o needed, otherwise daomatch stops...
#\r needed otherwise, with "y" only, daomatch stops
expect "*input*" {send "060326T002539353_4.als\r"}
expect "*transformation*" {interact -o "y\r" {return}}
#other inputs.....
现在,这个问题直到我把它标记为评论时才会出现(因为这是第一张糟糕的图片)。我通过键盘给出y\r。DAOMATCH一直工作到这个命令:我知道这一点,因为在输出中,我找到了所有的转换,包括我回答为“y\r”的最后一个转换

然而,在这一点上,情况就是这样

 060326T003521749_2.als           -48    33   0.999   0.010  -0.010   0.999   0.95

         3    0.805    0.000    0.000    0.020    0.012
         2    2.000    2.000    0.400    0.500
 WT  0.804957092  <    2

                        Write this transformation? 

                    Next input file (default EXIT): zaamus@zaamuspc:~/Documenti/Fits/GCs/Omega_Cen$
060326T003521749_2.als-48 33 0.999 0.010-0.010 0.999 0.95
3    0.805    0.000    0.000    0.020    0.012
2    2.000    2.000    0.400    0.500
重量0.804957092<2
写下这个转变?
下一个输入文件(默认退出):zaamus@zaamuspc:~/Documenti/Fits/GCs/Omega_Cen$
因此,不会执行最后一个预期。我试图改变超时,改变返回到inter_return,但我仍然没有解决这个问题


我知道这里有一些类似的问题,但我无法将expect封装在interact中,因为在一个失败后,我还有大约50-60个输入要提供。

无需担心。。。我找到了解决办法:我必须在#中添加a-c/usr/bin/expect

#!/usr/bin/expect -c

set timeout 1

spawn "~/myDaophot/daophot4/daomatch"

expect "*Master*" {send "060326T034700403_4.als\r"}
expect "*Output*" {send "060326T002448794_2_4.mch\r"}
expect "*input*" {send "060326T034700403_2.als\r"}
expect "*transformation*" {interact -o y\r {return} n\r {return}}
expect "*input*" {send "060326T034519602_4.als\r"}
expect "*transformation*" {interact -o y\r {return} n\r {return}}
expect "*input*" {send "060326T034519602_2.als\r"}
expect "*transformation*" {interact -o y\r {return} n\r {return}}
expect "*input*" {send "060326T002627552_4.als\r"}
expect "*transformation*" {interact -o y\r {return} n\r {return}}
expect "*input*" {send "060326T003255953_2.als\r"}
expect "*transformation*" {interact -o y\r {return} n\r {return}}
expect "*input*" {send "060326T003521749_2.als\r"}
expect "*transformation*" {interact -o y\r {return} n\r {return}}
expect "*input*" {send "060326T002539353_4.als\r"}
expect "*transformation*" {interact -o y\r {return} n\r {return}}
expect "*input*" {send "060326T002627552_2.als\r"}
expect "*transformation*" {interact -o y\r {return} n\r {return}}
expect "*input*" {send "060326T002715751_4.als\r"}
expect "*transformation*" {interact -o y\r {return} n\r {return}}
expect "*input*" {send "060326T002539353_2.als\r"}
expect "*transformation*" {interact -o y\r {return} n\r {return}}
expect "*input*" {send "060326T034457403_4.als\r"}
expect "*transformation*" {interact -o y\r {return} n\r {return}}
有一件事:我知道expect有一个非常严格的语法,但是Interactive只按照我在那里写的方式工作。如果我试着加上这样的括号

interact -o {y\r {return} n\r {return}}
这是行不通的