Linux ip port reachability check with specific error handling
AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution
npx -y skills add ECNU-ICALK/AutoSkill --skill linux-ip-port-reachability-check-with-specific-error-handlingAssembled 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
- Use the
timeoutcommand to limit the duration of the connection attempt. - Use
/dev/tcpornc(netcat) to attempt the connection. - 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.
- If the exit status is
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