问题描述
我一直在搞弄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设置中设置大容量存储设备,并在其中保存文本文件。