gpt4 book ai didi

windows - 使用 ActiveTcl 8.5 在 Windows 7 中的 tcl 脚本中运行 DOS 命令或批处理文件

转载 作者:可可西里 更新时间:2023-11-01 09:46:11 25 4
gpt4 key购买 nike

以下是tcl代码。

#!/bin/sh
# \
exec tclsh "$0" ${1+"$@"}

package require Expect
package require log
source [file join [info library] init.tcl]

set exp::winnt_debug 1

log::lvChannel debug stdout
log::log debug "debug msg ON\r"

set env(TERM) dumb

array set OPTS {
host ""
user ""
passwd ""
login telnet
prompt "(%|#|>|\\$) $"
ls "/bin/ls -A1"
}

set xlpad "yahoo.com"

exec [auto_execok dir]

while {1} {
spawn ping $xlpad
set loss 0
set replya 0
for { set pingc 0 } { $pingc < 3 } { incr pingc 1} {
expect {
"timed out" {
incr loss 1
puts "intercepted time out message: $loss\n"
}
"Reply" {
incr replya 1
}
}
if { $replya > 2 } {
break
}
}
break
}

return

我收到以下消息:

couldn't execute "C:\Windows\System32\cmd.exe \c dir": no such file or directory    while executing"exec [auto_execok dir]"    (file "mytst.tcl" line 35)

但 ping 正常。

最佳答案

auto_execok 返回一个列表,该列表作为单个参数传递给 exec。您需要扩展列表:

exec {*}[auto_execok dir]

例子:

% file mkdir tmp
% cd tmp
% close [open test w]
% exec [auto_execok dir]
couldn't execute "C:\WINNT\system32\cmd.exe \c dir": no such file or directory
% exec {*}[auto_execok dir]
Volume in drive D is Data
Volume Serial Number is ....

Directory of d:\glennj\tmp

2011-09-30 10:08 AM <DIR> .
2011-09-30 10:08 AM <DIR> ..
2011-09-30 10:08 AM 0 test
1 File(s) 0 bytes
2 Dir(s) 77,613,654,016 bytes free

关于windows - 使用 ActiveTcl 8.5 在 Windows 7 中的 tcl 脚本中运行 DOS 命令或批处理文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7604286/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com