Write a bash script which checks the Internet speed. We'll use the /tmp folder to…
- User
Write a bash script which checks the Internet speed. We'll use the /tmp folder to download a 100mb file using wget, removes the file, and displays the speed.
- Assistant
Sure, here's a simple bash script that achieves that:
#!/bin/bash # URL of a 100MB file URL="http://ipv4.download.thinkbroadband.com/100MB.zip" # Destination file path DESTINATION="/tmp/100MB.zip" echo "Starting speed test..." # Capture the start time START_TIME=$(date +%s) # Download the file with wget wget -O $DESTINATION $URL > /dev/null 2>&1 # Capture the end time END_TIME=$(date +%s) # Calculate the time taken TIME_TAKEN=$((END_TIME - START_TIME)) # Calculate the speed in kbps. We use 800 because there are 800 kilobits in 100MB. SPEED=$((800 / TIME_TAKEN)) # Remove the downloaded file rm $DESTINATION # Print the result echo "Speed: $SPEED kbps"
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.