PING an IP Address or hostname


I am new to PopClip and would like to create an extension for performing a “ping” to an IP address or hostname. I tried using a snipped but there are two questions I was not able to answer myself:

  1. When I have a shell script action, the action is run in the background. How can I get the “ping” commend to run in a new window in the foreground?
  2. Optional: I would like to test the input (selected) string to be a real formal IP address and only present the according extension icon if the string was suitable. Is that possible?


Hi again - sorry for asking too early, I was able to solve it. Here the working snippet if you are interested in the solution.

-- #popclip
-- name: Ping
-- icon:
-- regex: ^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))|((([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]))$
-- language: applescript
tell application "Terminal" to do script "ping {popclip text}"
1 Like

Hi Golo, this looks great – I’m curious why you bothered with the regular expression (which is pretty robust)?

Thanks! I wanted to show up the action only when a formal correct hostname or IP address is selected. And also a litte for fun :wink:

Nice solution.

Next challenge, add IPV6 support? :slight_smile:

Seems legit, didn’t figure out a quick solution myself so I gave Google a try: regex - Regular expression that matches valid IPv6 addresses - Stack Overflow Since I only need IPv6 once a year, I will skip this :face_with_peeking_eye:

1 Like