我写了一个 java 程序来运行带有 http 8080 的 ngrok 。成功执行 ngrok.exe 后出现跟随错误。如何获取特定输出并在控制台中打印而不是整个输出? String[] command = { "src/Ngrok/ngrok.exe", "src/Ngrok/ngrok.exe http 8080" }; String line; Process p; BufferedReader input = null; try { p = Runtime.getRuntime().exec(command); input = new BufferedReader( new InputStreamReader(p.getInputStream())); while ((line = input.readLine()) != null) { System.out.println(line); logsStatus.replaceSelection(line + "\n"); } } catch (IOException e) { e.printStackTrace(); } finally { if (null != input) { try { input.close(); } catch (IOException e) { e.printStackTrace(); } }按以下方式输出 && 错误 NAME: ngrok - tunnel local ports to public URLs and inspect trafficCOMMANDS: authtoken save authtoken to configuration file credits prints author and licensing information http start an HTTP tunnel start start tunnels by name from the configuration file tcp start a TCP tunnel tls start a TLS tunnel update update ngrok to the latest version version print the version string help Shows a list of commands or help for one command错误是这样的: ERROR: Unrecognized command: src/Ngrok/ngrok.exe http 8080
2 回答
慕森王
TA贡献1777条经验 获得超3个赞
这不起作用,因为该命令会ngrok http <port number>
打开一个新终端作为输出。我遇到了同样的问题,但在网上搜索后,我发现这个ngrok
命令curl -s localhost:4040/api/tunnels
返回一个JSON
对象,该对象定义了你想要的所有信息,包括公共 url。您在ngrok
http之后运行此命令并执行相同的方法它将起作用。
添加回答
举报
0/150
提交
取消