Last active
October 8, 2025 20:48
-
-
Save derekmahar/55ee9afd86ac46d3800eded777ecf32a to your computer and use it in GitHub Desktop.
Bash script that uses curl to retrieve exercise sources file from Python Morsels (pym.dev).
This file contains hidden or 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 | |
# Enable strict mode. | |
set -euo pipefail | |
IFS=$'\n\t' | |
if [[ $# != 2 ]] | |
then | |
echo "Usage: $0 [PASSWORD] [SOURCE_FILE_URL]" | |
exit 1 | |
fi | |
password=${1:-} | |
source_file_url=${2:-} | |
# Retrieve source file after submitting password form. | |
curl $source_file_url \ | |
--cookie "" \ | |
--form-string "form-name=form 1" \ | |
--form "password=$password" \ | |
--location-trusted \ | |
--remote-name \ | |
--silent |
This file contains hidden or 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 sh | |
# Set invalid password to intentionally hide the real one. | |
# Contact Trey Hunner ([email protected]) to get the real | |
# password or take his Modern Python Testing course on O'Reilly | |
# Learning (see https://tinyurl.com/2u5r5w8n)! | |
password=fake_password | |
# Retrieve exercise source file howdy.py. | |
./get_exercise_source_file.bash \ | |
$password \ | |
https://modern-testing.pym.dev/_downloads/c16bccf706c04a8a443ccc5c1eb3b3e7/howdy.py | |
# Retrieve exercise source file dollars.py. | |
./get_exercise_source_file.bash \ | |
$password \ | |
https://modern-testing.pym.dev/_downloads/6c71c5a6c266cbe29d7755889443b8c2/dollars.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment