#!/bin/bash function download { echo " " echo "Downloading... Please wait!" echo " " wget http://digital.inform.hu/Repository/SZFU/2008/$month/$day/SZFU.pdf -O $month-$day-SZFU.pdf # > /dev/null 2> /dev/null if [ $? == 1 ]; then #if6 echo "An error occured while downloading the newspaper" echo " " else mkdir -p ~/Documents/Szatmari\ Friss\ Ujsag/ > /dev/null 2> /dev/null mv $month-$day-SZFU.pdf ~/Documents/Szatmari\ Friss\ Ujsag/$month-$day.pdf echo "The newspaper was successful downloaded in: '$HOME/Documents/Szatmari Friss Ujsag/'" echo " " fi #if6 } read -p "Do you want to download today's newspaper? (yes/no) " mai if [ $mai == yes ] || [ $mai == no ]; then #if1 if [ $mai == yes ]; then #if2 sun="`date | awk '{print $1}'`" if [ $sun == Sun ]; then #if3 read -p "Today it's Sunday! -- NO newspaper today, shall I download the yesterday's? (yes/no) " kelle if [ $kelle == yes ] || [ $kelle == no ]; then #if4 if [ $kelle == yes ]; then #if5 day="`date | awk '{ print $3 -1 }'`" else echo "OK -- I'll not download!" exit fi #if5 else echo "Wrong answer!" exit fi #if4 else day="`date | awk '{ print $3 }'`" fi #if3 month="`date '+ %m' | awk '{ print $1 }'`" download else read -p "Month?: (e.g january = 01): " month if [[ $month == [0-1][0-9] && $month > "00" && $month < "13" ]]; then #if7 read -p "Day (e.g the 1st = 01): " nap if [[ $day == [0-3][0-9] && $day > "00" && $day < "32" ]]; then #if8 download else echo "Wrong Day!" exit fi #if8 else echo "Wrong Month!" fi #if7 fi #if2 fi #if