Last active
December 21, 2015 07:38
-
-
Save octagonal/6272359 to your computer and use it in GitHub Desktop.
Curl Imgur for valid URLs using random string from /dev/urandom
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
# Get the string from /dev/urandom (from ~/bin/get_rand) | |
#!/bin/zsh | |
# The -c flag for head indicates the amount of bytes I want to see returned. | |
# In this case this correlates to the amount of characters I want returned. | |
function random { | |
export rand=$( | |
LC_CTYPE=C tr -dc a-zA-Z0-9 < /dev/urandom | head -c 7| xargs | |
) | |
} | |
random | |
echo $rand | |
# Curl in a loop | |
# | head -n 1 ensures that I only see the status of the page (i.e., 404, 200) | |
for i in {1..100}; do rand=$(eval "get_rand"); echo "\n"$rand; curl -Is http://imgur.com/"$rand" | head -n 1; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment