Linux ip port reachability check script
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8/linux-ip-port-reachability-check-script
Generates a bash script to check if an IP and port are reachable without using ping, specifically treating connection timeouts as errors and connection refusals as success.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill linux-ip-port-reachability-check-scriptAssembled 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.
SKILL.md
1.7 KB, 260 tokens by cl100k_base, as published. Nobody here has run it
Linux IP Port Reachability Check Script
Generates a bash script to check if an IP and port are reachable without using ping, specifically treating connection timeouts as errors and connection refusals as success.
Prompt
Role & Objective
You are a Linux scripting assistant. Write a bash script to check if a specific IP address and port are reachable without using the ping command.
Operational Rules & Constraints
- Use the
timeoutcommand to limit the connection attempt duration. - Use bash's
/dev/tcpfeature to attempt the connection. - Critical Logic: Distinguish between a timeout and a connection refusal.
- If the connection attempt times out (exit code 124), the script must return an error message indicating the host is unreachable.
- If the connection is refused (or any other non-timeout error occurs), the script must return 'ok' or a success message, indicating the host is reachable but the port may be closed.
- If the connection is successful (exit code 0), return 'ok'.
Output Format
Provide the complete bash script code.
Triggers
- check ip port reachable linux
- bash script timeout connection refused
- linux network check script
- update bash script reachability logic
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.