Untitled
unknown
plain_text
2 months ago
1.5 kB
9
Indexable
#!/bin/bash # Check if a script was provided if [ $# -eq 0 ]; then echo "Usage: $0 <python_script.py> [arg1 arg2 ...]" exit 1 fi SCRIPT_NAME=$1 shift # Remove the script name from the arguments SCRIPT_ARGS="$@" # The rest of the arguments # List of Python versions to try PYTHON_VERSIONS=("python3.7" "python3.8" "python3.9" "python3.10" "python3.11") # Check if the script exists if [ ! -f "$SCRIPT_NAME" ]; then echo "Error: Script '$SCRIPT_NAME' not found" exit 1 fi echo "Running '$SCRIPT_NAME' with multiple Python versions..." echo "----------------------------------------" # Initialize counters SUCCESS_COUNT=0 FAILURE_COUNT=0 # Run the script with each Python version for PYTHON in "${PYTHON_VERSIONS[@]}"; do echo -n "Testing with $PYTHON: " # Check if this Python version is installed if command -v $PYTHON &> /dev/null; then echo -n "[$PYTHON version: $($PYTHON --version)] " # Run the script with this Python version if $PYTHON "$SCRIPT_NAME" $SCRIPT_ARGS; then echo "✅ Succeeded" ((SUCCESS_COUNT++)) else echo "❌ Failed (exit code: $?)" ((FAILURE_COUNT++)) fi else echo "⚠️ Not installed" fi done echo "----------------------------------------" echo "Summary: $SUCCESS_COUNT succeeded, $FAILURE_COUNT failed" echo "Python versions not in the list above are not installed on your system." # Make script executable chmod +x "$0"
Editor is loading...
Leave a Comment