Last active
August 24, 2023 13:24
-
-
Save LozanoMatheus/a3eb5a1fcc10661ff1e25ff1fe7c9e1e to your computer and use it in GitHub Desktop.
A simple request - HTTP request with native Bash and without curl/wget/*
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash +x | |
## Do you need to test your exposed app but you don't have curl/wget/* installed? | |
## The ":" is a built-in command and it works similar to true. Let's say, ":" is more portable than "true" | |
## Simple and easy | |
:> /dev/tcp/localhost/22 | |
## Why using timeout? If any side has a firewall and it's dropping the packages, the request will take ~80 seconds to get the timeout. | |
## Let's try first with Google :D | |
## In this case, we don't have output, but the return code will be 0 | |
timeout 10s bash -c ':> /dev/tcp/google.com/443' | |
## Return code | |
0 | |
## Now let's try locally. With return code 1 | |
timeout 10s bash -c ':> /dev/tcp/localhost/443' | |
## Output | |
bash: connect: Cannot assign requested address | |
bash: /dev/tcp/localhost/443: Cannot assign requested address | |
## Return code | |
1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment