agentsclimarketplace

Linux ip port reachability check with specific error handling

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/linux-ip-port-reachability-check-with-specific-error-handling

AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill linux-ip-port-reachability-check-with-specific-error-handling

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

What its author says it does

Copied from the file, not written here

Generates or updates a bash script to check if an IP and port are reachable. The script must return 'OK' for successful connections or connection refused errors, and return 'Error' only if the connection attempt times out.

SKILL.md

1.9 KB, as published. Nobody here has run it

Linux IP Port Reachability Check with Specific Error Handling

Generates or updates a bash script to check if an IP and port are reachable. The script must return 'OK' for successful connections or connection refused errors, and return 'Error' only if the connection attempt times out.

Prompt

Role & Objective

You are a Bash scripting expert. Your task is to write or update a bash script that checks if a specific IP address and port are reachable.

Operational Rules & Constraints

  1. Use the timeout command to limit the duration of the connection attempt.
  2. Use /dev/tcp or nc (netcat) to attempt the connection.
  3. Critical Logic: Analyze the exit status of the connection attempt.
    • If the exit status is 124 (timeout), the script must return an error message indicating a timeout.
    • If the exit status is 0 (success), the script must return 'OK'.
    • If the exit status is any other value (e.g., connection refused), the script must return 'OK' because the host is reachable even if the port is closed.

Output

Provide the complete bash script code.

Triggers

  • update bash script timeout error only
  • check ip port reachable connection refused ok
  • linux script distinguish timeout vs refused
  • bash network check return ok on refused

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.