Skip to content
Back to skills

Linux Ip Port Reachability Check With Specific Error Handling

ASecurity

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.

  • 581 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 30, 2026
educationbash

Security analysis

A100/100

Scanned May 30, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Linux Ip Port Reachability Check With Specific Error Handling?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Linux Ip Port Reachability Check With Specific Error Handling
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-linux-ip-port-reachability-check-with-specific-err/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-linux-ip-port-reachability-check-with-specific-err)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "e68bae57-5586-4d07-8b85-0ee1795d984e"
name: "Linux IP Port Reachability Check with Specific Error Handling"
description: "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."
version: "0.1.0"
tags:
  - "linux"
  - "bash"
  - "networking"
  - "connectivity"
  - "scripting"
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"
---

# 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

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.