尝试通过Tarantool LUA管理控制台读取文件时尝试索引全局“io”错误

时间:2016-10-30 08:09:42

标签: lua tarantool

我有一个问题。 为什么我无法访问Tarantool LUA管理控制台中的文件? 我在监狱吗?

tarantool -h myhost -a 33015
help

console client commands:
- help
- loadfile 'path'
- setopt key=val
- (possible pairs: delimiter = 'string' )
- ( pager = 'command' )
...
---
available commands:
- help
- exit
- show info
- show fiber
- show configuration
- show slab
- show palloc
- show stat
- show plugins
- save coredump
- save snapshot
- lua command
- reload configuration
- show injections (debug mode only)
- set injection <name> <state> (debug mode only)
...


myhost> lua file = io.open("/etc/motd", "r")

attempt to index global ''io''

我都不能使用套接字模块:

[string "local s=require(''socket'');local t=assert(s.tc..."]:1: attempt to call global ''require''

是否可以从Tarantool LUA控制台内部读取文件和执行命令?

1 个答案:

答案 0 :(得分:0)

Lua是extensible, embeddable language。不要求使用该语言的主机程序打开标准库。因此,并非所有使用Lua的程序都会打开iopackage库。相反,他们可能会选择实施并随后打开他们自己的库。

您正在寻找的Tarantool模块是fio,同样名为fio.open

file_handle = fio.open('/etc/motd', { 'O_RDONLY' })

请注意,Tarantool还有一个内置的socket模块。

来源: