SOLVED wget or curl to download mint iso

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
buteman
Level 4
Level 4
Posts: 331
Joined: Tue Nov 29, 2011 5:36 pm
Location: North Lincolnshire

SOLVED wget or curl to download mint iso

Post by buteman »

Hi all,

New to mint but not linux. I would like to run an at job to download mint during the night as it doesn't count towards my monthly download allowance.

I have some questions though.

1/ Is it best to use wget or curl?

2/ how can I find the correct url for the download?

tia

norman
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Habitual

Re: wget or curl to download mint iso

Post by Habitual »

Code: Select all

wget http://path/to/download/file.iso
buteman
Level 4
Level 4
Posts: 331
Joined: Tue Nov 29, 2011 5:36 pm
Location: North Lincolnshire

Re: wget or curl to download mint iso

Post by buteman »

Habitual wrote:

Code: Select all

wget http://path/to/download/file.iso
I have tried to use that synatx but without knowing what the path is it cannot succeed so i guess my question should have been:

what is the path to the isos on this site?

or are they not here? In which case what is the correct path?
tia,
Norman
Anakinholland

Re: wget or curl to download mint iso

Post by Anakinholland »

You didn't answer either of his questions Habitual.

buteman,

From what I've read in the last couple of minutes it comes down to a matter of taste. I've never used curl, and only ever used wget a couple of time to add pgp-keys to apt :P

However, with what I' ve seen here for instance, my pick would be curl.

As for which URL, you didn't state which download you wanted...

If you go to the downloads page, you can pick whatever you like. For instance click the Linux Mint 12 32bit DVD-edition: http://www.linuxmint.com/edition.php?id=94

On that new page you can just pick any Primary download mirror. :)

Regards,

Anakin
buteman
Level 4
Level 4
Posts: 331
Joined: Tue Nov 29, 2011 5:36 pm
Location: North Lincolnshire

Re: wget or curl to download mint iso

Post by buteman »

Anakinholland wrote:You didn't answer either of his questions Habitual.

buteman,

From what I've read in the last couple of minutes it comes down to a matter of taste. I've never used curl, and only ever used wget a couple of time to add pgp-keys to apt :P

However, with what I' ve seen here for instance, my pick would be curl.

As for which URL, you didn't state which download you wanted...

If you go to the downloads page, you can pick whatever you like. For instance click the Linux Mint 12 32bit DVD-edition: http://www.linuxmint.com/edition.php?id=94

On that new page you can just pick any Primary download mirror. :)

Regards,

Anakin
Well you can probably say I am dumb but I want to run it from an 'at' job so it will be command line e.g at now +4hours curl -C ?????????????????????
which means the operation will run during the time which is not counted in my monthly download allowance - which means i need it to run sometime between midnight and 7a.m
where of course ?????????????? is the path which is what I have not been able to figure out.
Anakinholland

Re: wget or curl to download mint iso

Post by Anakinholland »

buteman,

If you go to the page I linked (http://www.linuxmint.com/edition.php?id=94) hover over any of the links of the primary mirrors, you will the the URL in the bottom bar.

With using Firefox or Opera, just right-click a link and select "Copy Link Address", it's now in the memory. Paste in a terminal using Ctrl+Shift+V or Shift+Insert.

In my case, for some reason HEAnet has always performed remarkably for me, even though it's a site abroad, so I would pick http://ftp.heanet.ie/pub/linuxmint.com/ ... -32bit.iso

Regards,

Anakin

P.S. Maybe you can "abuse" this article to download the file in parts and never download during daytime? :)
buteman
Level 4
Level 4
Posts: 331
Joined: Tue Nov 29, 2011 5:36 pm
Location: North Lincolnshire

Re: wget or curl to download mint iso

Post by buteman »

Thanks Anakin,

It's now waiting to start the download.
Had a look at the link and think I will 'abuse' it.
Might write a bit of python which would take the url as a user input and do the splitting and timing
followed by the concatenating.
Hmm wonder if I can get it to launch K3B and burn the disc as well?

buteman

update >>>>> just did a quick check and k3b can be launched from command line so it looks like I am set to go :D
Habitual

Re: wget or curl to download mint iso

Post by Habitual »

Anakinholland wrote:You didn't answer either of his questions Habitual.
A guy who doesn't know curl from wget or an address to the ISO, but can "write a bit of python which would take the url as a user input and do the splitting and timing followed by the concatenating."?

I gave all I'm gonna. Incentive.
buteman
Level 4
Level 4
Posts: 331
Joined: Tue Nov 29, 2011 5:36 pm
Location: North Lincolnshire

Re: wget or curl to download mint iso

Post by buteman »

Appreciate your comment habitual. I realize you may have vastly more knowledge than me.
I spent several hours recently trying to do a similar download of ubuntu stuff. I had done just as anakin has spelled out to me but it failed.

One said that the url was too long. I had simply copied and pasted it to the end of the wget command.

There where many different errors.

One ended up with a lot of what appeared to be junk like this :
5�+����\VQ�kT`{^����R��
'^B@���� ����[�
��k�Z_��-Zuf`:*:#�-+;
�O���W�0�I��G�P�5�O� �hS�)�~u
s/|����|����%���N�OP�4b�
�nA'�u�IV�

So that was the reason for my post.
Anyway I will post my python code for your comments when I finish it.
Perhaps you will be able to help me improve it so it can benefit others.

As a matter of interest maybe I downloaded what I wanted with:

curl -C - -O http://ftp.heanet.ie/pub/linuxmint.com/ ... -32bit.iso
Habitual

Re: wget or curl to download mint iso

Post by Habitual »

I have always used wget for single files, EXCEPT when I want to suck down the source of an index.* document.
It just works.

After you grab the iso in whatever fashion works for you,
the next step is verify the md5sum hash against the download.iso

Terminal >

Code: Select all

md5sum ~/Downloads/linuxmint-12-gnome-dvd-32bit.iso 
and compare with these (from http://linuxfreedom.com/linuxmint/linux ... md5sum.txt)
ee3d6e2ca498bc7685b7f17cdb5f2eea linuxmint-12-gnome-dvd-32bit.iso

Burn at MaxSpeed-1
Python has urllib2
Good Luck.

Edit:

Code: Select all

wget http://ftp.heanet.ie/pub/linuxmint.com/stable/12/linuxmint-12-gnome-dvd-32bit.iso
buteman
Level 4
Level 4
Posts: 331
Joined: Tue Nov 29, 2011 5:36 pm
Location: North Lincolnshire

Re: wget or curl to download mint iso

Post by buteman »

Well I have ( I think ) written a working bash script rather than some python so maybe you can have a look and see what you think.
I have set it going to download an iso later tonight.
If you copy it and save it you will need to make it executable with :

Code: Select all

chmod +x whatever-you-called-it

Code: Select all

#!/bin/bash
# Max CD size is assumed to be 71680000 bytes
:<<COMMENT 
This program allows you to copy and paste a link to an iso and its md5sum 
from the  Mint downloads page ( or any other site ).  
It will download the iso, check it has the correct md5 and then 
works out whether you need to burn to CD or DVD.
It will advise you which is needed and wait until you put the correct disc in the 
drive before burning it to disc.
You get to choose if you want to download the iso and burn it now
or if you want to leave it until after midnoght to download and burn it unattended.

COMMENT

# This function will wait to start download if called from main part of script

function wait_for_10_past_midnight 
{
STARTTIME=`date +%k%M`

TIMENOW=$STARTTIME
ENDTIME=2358
clear
echo ""
echo ""
echo "                 Make sure you have a CD or DVD in the drive"
echo "                 >>>>     Make sure the file will fit   <<<<"
sleep 10
while [ `date +%k%M` -le "$ENDTIME" ]
do
	clear
	echo ""
	echo ""
	echo "          Waiting ."
	sleep 2
	clear
	echo ""
	echo ""
	echo "          Waiting . ."
	sleep 2
	clear
	echo ""
	echo ""
	echo "          Waiting . . ."
	sleep 2
	clear
	echo ""
	echo ""
	echo "          Waiting . . . ."
	sleep 2
	clear
	echo ""
	echo ""
	echo "          Waiting . . . . ."
	sleep 2
	clear
	echo ""
	echo ""
	echo "          Waiting . . . . . ."
	sleep 2
	clear
	echo ""
	echo ""
	echo "          Waiting . . . . . . ."
	sleep 2
	clear
	echo ""
	echo ""
	echo "          Waiting . . . . . . . ."
	sleep 2
	clear
	echo ""
	echo ""
	echo "          Waiting . . . . . . . . ."
	sleep 2

done
echo "Done"
# Alter the sleep time ( 60 = 1 minute ) for different delay time
sleep 600
wget "$FN"
echo ""
ACTUAL=`md5sum "$MYFILE"`
echo ""
set -- "$ACTUAL"
MYACT=$1
if [ "$LN" = "$MYACT" ]; then
	echo "Writing iso to Disc"
	echo "This is my file name: $MYFILE"

	wodim --scanbus|sort>MYDEVS
	MYDVD1=`head -n 1 ./MYDEVS`
	MYDVD=${MYDVD1:1:5}
	wodim -v dev=$MYDVD  $MYFILE	
else 
	echo "          MD5sums did not match so no disc created"	
fi
}

# This is the start of the main program
clear
echo ""
echo ""
echo "Please enter the link to the iso you want to download. "
read FN 
echo ""
echo ""
echo "Please enter the md5 from the web page." 
read LN
MYFILE=`basename "$FN"`

echo ""

myval=0
while [ $myval = "0" ]
do 
	clear
	echo "$myval"
	echo ""
	echo ""
	echo ""
	echo ""
	echo "Do you wish to download the file and burn the disc now (Y/n)"
	read CH
	echo "$CH"
	if [  "$CH" = "Y"  ] || [  "$CH" = "y"  ]; then
		myval=1
		echo "Myval is $myval"
	fi

	if [ "$CH" = "N" ] || [ "$CH" = "n" ]; then
		myval=2
	fi
done

if [ "$myval" -eq 2 ]; then
	wait_for_10_past_midnight

else 
	echo "Please wait while $MYFILE  is downloaded"

	wget "$FN"
	echo ""

	ACTUAL=`md5sum "$MYFILE"`
	echo ""
	set -- "$ACTUAL"
	MYACT=$1
	echo "$MYACT1">./tempfile
	MYACT=`cut -f1 -d' ' ./tempfile`
	if [ "$LN" = "$MYACT" ]; then
		FILESIZE=`stat -c%s "$MYFILE"`
		if [   "$FILESIZE"  =  716800000  ]; then
			echo "Make sure a CD is in the burner"
			else
			echo "Make sure there is a DVD in the burner"
		fi	
		echo "Press Enter to continue"
		read ANS

		echo "Writing iso to Disc"
		echo "This is my file name: $MYFILE"

		wodim --scanbus|sort>MYDEVS
		MYDVD1=`head -n 1 ./MYDEVS`
		MYDVD=${MYDVD1:1:5}
		wodim -v dev=$MYDVD  $MYFILE		
	
	else
	echo " md5sums not a match so not burning disc!"
	fi
fi
Hoping this will be of use to others.
Last edited by buteman on Sat Dec 10, 2011 8:06 am, edited 1 time in total.
Anakinholland

Re: wget or curl to download mint iso

Post by Anakinholland »

First of all: Great effort!! It only took me a few moments to catch your intentions, and I also learned a couple new tricks (the ":<< COMMENT" and "basename" were new to me)! :)

I did however notice some stuff which was obsolete, didn't make sense or just not tidy (couldn't find a better term), quite possibly because of differences between the various languages/interpreters you are used to?

I did the following:
  • Moved the remark about maximum CD-size to the point where you actually do the check.
  • Removed "STARTTIME=`date +%k%M`" and "TIMENOW=$STARTTIME" as you're not using those variables anywhere in the script.
  • Changed the "while less or equal"-loop for the waiting for 2358 into a "until equal"-loop waiting for 0008. It will work because you check every 16 seconds, so you have 3 or 5 100% chances to hit the mark.
  • Changed the until-loop for the waiting for 0008 using an array which gets reset occasionally, as this is much neater and more dynamic if you ever want to change the duration.
  • Moved the downloading and md5check into a function as you're doing the same thing twice.
  • Removed the while-loop around "Do you wish to download the file and burn the disc now", merged the input-check and moved it into a function, as that is much neater.
  • Moved the burn-echoes and -commands into a function as you're doing the same thing twice.
  • Removed the ACTUAL/MYACT-actions as it's redundant, moved "md5sum "$MYFILE"" into the if-statement.
  • Removed the FILESIZE-action as it's redundant, moved "stat -c%s "$MYFILE"" into the if-statement.
  • Moved function wait_for_10_past_midnight into the last if-statement as you're only doing it once.
  • Moved dual "echo """ into a function, as you're doing that often.
  • Added a 0 to 71680000, as you were checking on 71.6MB, not 716MB.
  • Moved the wget and md5-check into a function as you're doing the same thing twice.
  • Added {} to all variables as that's better practice, so it will delimit the name and you can use extra functionality. For example, in case you ever want to use timestamps or text linked to a variable. "$var1bla.txt" will not work, but "${var1}bla.txt" will. More info can be found here
  • Changed all "echo """ to just "echo" as it does the same, and eliminates forgetting a quote resulting in the script not running.
  • Changed all [ ] into [[ ]] as it works better in most (if not all) cases, has more features and does not invoke external commands (so it will be quicker and less intrusive), but will not work in a POSIX-environment like for instance Busybox. More info can be found here and here.
The script now looks like this:

Code: Select all

#!/bin/bash

:<<COMMENT 
This program allows you to copy and paste a link to an iso and its md5 
from the  Mint downloads page ( or any other site ).  
It will download the iso, check it has the correct md5 and then 
works out whether you need to burn to CD or DVD.
It will advise you which is needed and wait until you put the disc in the 
drive before burning it to disc.
You get to choose if you want to download the iso and burn it now
or if you want to leave it until after midnight to download and burn it unattended.
If you choose to burn it later you will have to put a CD or DVD in the drive when you run it
so it can burn it when the download and md5sum are finished.

COMMENT

function dual(){

# Just add 2 blank lines to the output

	echo
	echo
}

function checkinput(){

# This function checks user for input

   echo "Do you wish to download the file and burn the disc now (Y/n)"
   read CH
   if [[  "${CH}" != [YyNn] ]]
   then
      echo "Invalid entry, press Enter to try again."
      read blablabla
      check
   fi
   export CH
}

function wgetfile(){
	wget "${FN}"
	dual
		if [[ "${LN}" != `md5sum "${MYFILE}"` ]]
	then
		echo " md5sums not a match so not burning disc!"
		exit 4
	fi
}

function burn(){

# Actually put the image on the disc	
	
	echo "Writing iso to Disc"
	echo "This is my file name: ${MYFILE}"
	
	wodim --scanbus|sort>MYDEVS
    MYDVD1=`head -n 1 ./MYDEVS`
    MYDVD=${MYDVD1:1:5}
    wodim -v dev=${MYDVD} ${MYFILE}
}

# Start of the main program
clear
dual
echo "Please enter the link to the iso you want to download. "
read FN 
dual
echo "Please enter the md5 from the web page." 
read LN
MYFILE=`basename "${FN}"`
echo

checkinput

if [[ "${CH}" == [Nn] ]]
then
	ENDTIME=0008
	clear
	dual
	echo "                 Make sure you have a CD or DVD in the drive"
	echo "                 >>>>     Make sure the file will fit   <<<<"
	echo
	sleep 10
	until [[ `date +%k%M` -eq "${ENDTIME}" ]]
	do
		if [[ ${counter} -gt 7 ]] || [[ -z ${counter} ]]
		then
			counter=0
			dots=("          Waiting .")
		fi
		clear
		echo ${dots[@]}
		dual
		sleep 2
		dots=("${dots[@]}" ".")
		counter=`expr ${counter} + 1`
	done
	echo "Done"
	wgetfile
else
	echo "          Please wait while ${MYFILE}  is downloaded"
	wgetfile
	
	# Max CD size is assumed to be 71680000 bytes
	
	if [[ `stat -c%s "${MYFILE}"` -le  716800000  ]]
	then
		echo "Make sure a CD is in the burner"
	else
		echo "Make sure there is a DVD in the burner"
	fi   
	echo "Press Enter to continue"
	read ANS
fi

burn
Sadly I cannot test the script myself at the moment, as I don't have any blank discs or a broadband-connection at the moment, but it should work :)

Once again, I applaud the effort, the script will work (apart from the fact that it will almost always ask for a DVD :) ), I just wanted to give some pointers on how it can be even better. :D

Anakin
buteman
Level 4
Level 4
Posts: 331
Joined: Tue Nov 29, 2011 5:36 pm
Location: North Lincolnshire

Re: wget or curl to download mint iso

Post by buteman »

Thanks to anakin I now have a much better script. As I pointed out to him in a p.m it was my first script so I am not surprised it could be improved.

Now marked as solved.
Locked

Return to “Other topics”