【发布时间】:2013-04-06 05:32:58
【问题描述】:
假设我有一个简单的expect 脚本(simple.exp):
set command "ls -l somedir"
spawn $command
interact
执行此脚本会导致错误,因为expect 将 ls -l(带有空格的整个字符串)视为命令而不是 ls 作为命令和 -l 作为选项:
expect -f simple.exp
spawn ls -l
couldn't execute "ls -l somedir": no such file or directory
while executing
"spawn $command"
(file "simple.exp" line 2)
我想要的是类似于bash 的行为,它首先处理字符串并将其分解为不同的参数以启动命令:
bash -c "ls -l somedir"
请注意,为简单起见,变量command 在脚本中进行了硬编码。在实际脚本中,它作为参数提供(任意命令行字符串)。
【问题讨论】:
标签: expect