将MacOS终端输出保存在HID脚本变量中

问题描述

我一直在搞弄P4wnP1,试图用MacOS进行笔测试。为了使程序正常工作,我需要使用HID脚本将本地IP地址保存在文本文件中。

代码如下:

//Language and typing speed
layout('us')
typingSpeed(0,0)

//Open terminal
press(“GUI” + “SPACE”)
type(“terminal”)
press(“ENTER”)
delay(500)

//Find local IP address
type(“export IP_ADDR=/ipconfig getifaddr en0”)
press(“ENTER”)
//**Export IP_ADDR to .txt file in pi0w home directory**

Currently,I can get the correct output,but I do not know how to extract the data

编辑:我忘了提及,HIDScript基于JavaScript,并具有可用的通用库

解决方法

如果要求在文本文件中捕获IP,则可以使用如下管道:

type(“export IP_ADDR=/ipconfig getifaddr en0 >/tmp/ipaddr.txt\n”)

注意:\n表示您不必使用回车键。

您可以在USB设置中设置大容量存储设备,并在其中保存文本文件。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...