函数:os.execute 执行 shell 命令

函数名称:执行 shell 命令

函数功能:执行 shell 命令

函数方法

flag = os.execute(command)

参数 类型 必填 说明
command string 需要执行的 shell 命令
返回值 类型 说明
flag - 成功 → 返回 true、"exit" 、 0,
失败 → 返回 nil、"exit" 、 终止码(或 "signal"、信号值)

注意事项

  • 不支持 iOS 小精灵。

  • iOS11 以上系统不支持 os 函数,请按照以下系统更换代码。

  • iOS 11~14、15、16 系统有根越狱,可以使用以下代码

    自定义操作 = "" --请填写需要执行的命令
    ts_execute("/usr/bin/killall "..自定义操作)
    
  • 15 以上系统隐根越狱可以使用以下代码

    local ts = require("ts")
    function getKillallPath()
        tableGet = ts.hlfs.getFileList("/var/containers/Bundle/Application",true)
        if tableGet then
            for i,v in pairs(tableGet) do
                if v:match("^%.jbroot%-") ~= nil then return "/var/containers/Bundle/Application/" .. v end
            end
        else
            dialog("没有找到指定目录")
            lua_exit()
        end
    end
    自定义操作 = "" --请填写需要执行的命令
    ts_execute(getKillallPath() .. "/usr/bin/killall "..自定义操作)
    
  • 15 以上系统无根越狱可以使用以下代码
    自定义操作 = "" --请填写需要执行的命令
    ts_execute("/var/jb/usr/bin/killall "..自定义操作)
    
Copyright 北京帮你玩科技有限公司 2026 all right reserved,powered by Gitbook该文章修订时间: 2026-06-16 18:27:40

results matching ""

    No results matching ""