Shell output in Applescript
我想知道如何从Applescript中的shell命令的输出中仅提取某些数据。 我希望能够只通过"ping -o"命令将IP地址传递给变量,如下所示:
1 2 3 4 5 | do shell script"ping -o" & blockedURL -- Set the IP to blockedIP -- set blockedIP to .. |
但我收到了这个:
"PING example.com (192.0.43.10): 56 data bytes 64 bytes from
192.0.43.10: icmp_seq=0 ttl=239 time=101.587 ms--- example.com ping statistics --- 1 packets transmitted, 1 packets received, 0.0% packet loss round-trip min/avg/max/stddev =
101.587/101.587/101.587/0.000 ms"
当我执行ping命令时,我收到了很多我不需要的数据。 有没有办法只能召回
1 2 3 4 5 6 7 8 9 | set a to"PING example.com (192.0.43.10): 56 data bytes 64 bytes from 192.0.43.10: icmp_seq=0 ttl=239 time=101.587 ms --- example.com ping statistics --- 1 packets transmitted, 1 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 101.587/101.587/101.587/0.000 ms" set text item delimiters to"(" set temp to text item 2 of a set text item delimiters to")" set temp to first text item of temp return temp |
以上是一个完整的AppleScript解决方案。 您也可以使用以下内容来获取IP只使用shell