Register
It is currently Sun Nov 23, 2014 6:17 am

Script to download pdfs quit working after over a year...


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Fri Apr 24, 2009 7:53 pm   

Joined: Fri Apr 24, 2009 7:29 pm
Posts: 3
I crafted this bash script after reading advise on this forum. This script has created a directory and downloaded the pdfs from the local paper daily into it for over a year. Then after I upgraded to Ubuntu Jaunty 9.04 it suddenly quit working. I get the following error. Can anyone help me figure out why this quit working? It actually seems like it is downloading to somewhere but it no longer creates the directory for the date anymore.

Quote:
/home/username/Newspaper/downloadtulsaworld.sh: line 2: verbose: command not found
: command not foundpaper/downloadtulsaworld.sh: line 12:
--2009-04-24 20:40:29-- http://www.tulsaworld.com/TWPDFs/2009/F ... 09_A_1.pdf
Resolving http://www.tulsaworld.com... 209.184.242.1
Connecting to http://www.tulsaworld.com|209.184.242.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 707493 (691K) [application/pdf]
Saving to: `W_042409_A_1.pdf.11'


Here is my script...

Code:
#!/bin/bash
verbose
cd /home/username/Newspaper

# datadir is the directory you want the paper saved to:
datadir=$(date +%Y-%m-%d)

# create datadir if necessary:
mkdir -p $datadir

cd $datadir


wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_1.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_2.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_3.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_4.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_5.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_6.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_7.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_8.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_9.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_10.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_11.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_12.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_13.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_14.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_15.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_16.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_17.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_18.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_19.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_20.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_21.pdf
wget http://www.tulsaworld.com/TWPDFs/2009/Final/W_`date '+%m%d%y'`_A_22.pdf


Top
 Profile  
 PostPosted: Sat Apr 25, 2009 8:14 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 673
Location: Des Moines, Iowa
A couple things.

The verbose command isn't showing up... .ie: it's not found.
If it's there, you can type

type verbose

to see it's full path if it's actually there, and use the full path in the script to call it... otherwise, look into installing it, or just comment it out of the script.

Is the Newspaper directory created ?? Is it created as "News paper" with a space in it by chance ??? if so, recreate it with no space, or enclose your variable with { }
example:

Code:
mkdir -p $datadir

cd $datadir


to this

Code:
mkdir -p ${datadir}

cd ${datadir}


Hopefully that clears up the issues your having.


Top
 Profile WWW  
 PostPosted: Sat Apr 25, 2009 11:58 am   

Joined: Fri Apr 24, 2009 7:29 pm
Posts: 3
That fixed it. Thanks a ton. The script creates a directory named the date it downloads (i.e. 2009-04-25). So that way if I forget the next days paper will not overwrite the day's before paper. Must have been some changes to bash in Jaunty. I am pretty new to Bash scripts and this was my first one.

Thanks!


Top
 Profile  
 PostPosted: Sat Apr 25, 2009 12:42 pm   

Joined: Fri Apr 24, 2009 7:29 pm
Posts: 3
Do you know if it is possible to for me to make the script check if the pdf is available and use wget only if it is available? Right now it downloads all the possible pages and if there is not a pdf there it still creates an zero data pdf file that I just delete later on.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP