Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, July 19, 2011

Simple Script to Download epaper from Mid-Day


#!/bin/bash
#ishan dot karve at gmail dot com
#Script to download epaper from mid-day.com
#As always /// Its free to use...
#Get user to select edition
edition_choice=([0]=mumbai [1]=delhi [2]=bangalore [3]=pune)
edition_abbr=([0]=md-mn [1]=md-dn [2]=md-bn [3]=md-pn)
echo "Mid-Day epaper editions are"
echo "-------------------------------------------------"
echo "0. Mumbai"
echo "1. Delhi"
echo "2. Bangalore"
echo "3. Pune"
echo "-------------------------------------------------"
while true; do
    read -p "Enter edition you wish to selec[0-9]: " ed
    case $ed in
       [0123]) 
 echo "Thanks." 
 break;;
        * ) echo "Please select the correct numeric serial.";;
    esac
done
#Get user to input starting page
read -p "Please enter the starting page you wish to download from?" strt_pg
#Get user to input ending page
read -p "Please enter the ending page you wish to download?" end_pg
while true; do
    read -p "Do you wish download pages $strt_pg to $end_pg? [Y/N]" yn
    case $yn in
        [Yy]* ) 
    for ((  i = $strt_pg ;  i <= end_pg;  i++  ))
    do
      echo "Downloading Page $i"

      I_FILE="http://epaper2.mid-day.com/DRIVE/${edition_choice[ed]}/`date +%d``date +%m``date +%Y`/epaperpdf/19072011-${edition_abbr[ed]}-$i.pdf"
      wget $I_FILE 
    done
     break;;
        [Nn]* ) exit;;
        * ) echo "Please answer yes or no.";;
    esac
done







How to get it running

Copy the script to your Linux desktop
 go to command prompt using terminal
 type following commands

cd ~/Desktop
chmod +x milk_day.sh
./milk_day.sh

Simple Script to Download epaper from Indian Express

#!/bin/bash
# ishan dot karve at gmail dot com
#Script to download epaper from indian express
#As always /// Its free to use...
clear
curl -s http://epaper.indianexpress.com > /tmp/editions
temp1=$(sed -nr 's/(.*)max-height:none;" src="?([^ ">]*).*/\2\n\1/; T; P; D;' /tmp/editions) 
temp2=$(sed -n -e 's/.*<span class="caption">\(.*\)<\/span>.*/\1/p' /tmp/editions)
editions=($(echo $temp2 | tr " " "\n"))
editions_link=($(echo $temp1 | tr " " "\n"))
echo "Following ${#editions[*]} Editions available for download"
count=0
for i in "${editions[@]}"
do
 echo $count.  $i
 count=$((count+1))
done
while true; do
    read -p "Enter edition you wish to select[0-9]: " ed
    case $ed in
       [0123456789]) 
echo "Processing..." 
break;;
        * ) echo "Please select the correct numeric serial.";;
    esac
done

if [ "$ed" -ge "${#editions[*]}" ]
then
echo "Please select proper edition. Please try again. Bye."
exit 0
fi

links=${editions_link[$ed]}
#grab edition id
edition_id=($(echo $links | cut -d "/" -f4))
#Get user to input starting page
read -p "Please enter the starting page you wish to download from?" strt_pg
#Get user to input ending page
read -p "Please enter the ending page you wish to download?" end_pg
while true; do
    read -p "Do you wish download pages $strt_pg to $end_pg? [Y/N]" yn
    case $yn in
        [Yy]* ) 
 ty_dir="$HOME/Desktop/ie_day_`date +%d``date +%m``date +%Y`"
 mkdir $ty_dir

 for ((  i = $strt_pg ;  i <= end_pg;  i++  ))
 do
#prepend zero to single digits
      pageno=`printf "%02d" $i`  
      echo "Downloading Page $pageno"
      O_FILE="$ty_dir/$pageno.pdf"
      I_FILE="http://epaper.indianexpress.com/pdf/get/$edition_id/$i"
   wget -O $O_FILE $I_FILE 
 done
  break;;
        [Nn]* ) exit;;
        * ) echo "Please answer yes or no.";;
    esac
done
#combine multiple pdf files
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=ie_`date +%d``date +%m``date +%Y`.pdf -dBATCH $ty_dir/*.pdf
#empty directory
rm $ty_dir/*.*
#remove directory
rmdir $ty_dir



How to get it running

Copy the script to your Linux desktop
 go to command prompt using terminal
 type following commands

cd ~/Desktop
chmod +x milk_express.sh
./milk_express.sh

Tuesday, July 12, 2011

Simple Script to Download epaper from Times of India

#!/bin/bash
#Written for a friend in need
#Script to download epaper from indiatimes.com
#As always /// Its free to use...
#Get user to select edition
edition_choice=([0]=TOIM [1]=CAP [2]=TOIB [3]=TOIKM [4]=TOICH [5]=TOIPU [6]=TOIA [7]=TOIL [8]=TOIJ [9]=TOIH)
echo "Times of India epaper editions are"
echo "-------------------------------------------------"
echo "0. Mumbai"
echo "1. Delhi"
echo "2. Bangalore"
echo "3. Kolkata"
echo "4. Chennai"
echo "5. Pune"
echo "6. Ahmedabad"
echo "7. Lucknow"
echo "8. Jaipur"
echo "9. Hyderabad"
echo "-------------------------------------------------"
while true; do
    read -p "Enter edition you wish to selec[0-9]: " ed
    case $ed in
       [0123456789]) 
 echo "Thanks." 
 break;;
        * ) echo "Please select the correct numeric serial.";;
    esac
done
#Get user to input starting page
read -p "Please enter the starting page you wish to download from?" strt_pg
#Get user to input ending page
read -p "Please enter the ending page you wish to download?" end_pg
while true; do
    read -p "Do you wish download pages $strt_pg to $end_pg? [Y/N]" yn
    case $yn in
        [Yy]* ) 
    for ((  i = $strt_pg ;  i <= end_pg;  i++  ))
    do
      echo "Downloading Page $i";
      I_FILE="http://epaper.timesofindia.com/Repository/${edition_choice[ed]}/`date +%Y`/`date +%m`/`date +%d`/${edition_choice[ed]}_`date +%Y`_`date +%-m`_`date +%d`_$i.pdf"
      wget $I_FILE 
    done
     break;;
        [Nn]* ) exit;;
        * ) echo "Please answer yes or no.";;
    esac
done


How to get it running

Copy the script to your Linux desktop
 go to command prompt using terminal
 type following commands

cd ~/Desktop
chmod +x test_1.sh
./test_1.sh


14 Jul 2011 0026 : Script updated to reflect various editions....

Sunday, October 17, 2010

Configuring Soundgraph FingerVU 706 on Ubuntu 10.04

This is the first post on my blog. As the title suggests, this blogs describes how to configure Soundgraph USB Monitor FingerVU 706 to work as an extended monitor on Ubuntu 10.04 (32 bit).  ( Presently the monitor works only as a display and I have not been able to configure the remote control or touch screen input)

Due to paucity of time and most importantly patience, the guide is written in 'Cut the crap out' style.

Before one proceeds ahead it is important that your system is updated and has latest updates installed.

sudo aptitude update
sudo aptitude upgrade



Once you have achieved this, it is time to get new kernel updates


cd ~/Desktop
mkdir new_kernel
cd new_kernel

wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.34-lucid/linux-headers-2.6.34-020634_2.6.34-020634_all.deb
dpkg -i linux-headers-2.6.34-020634_2.6.34-020634_all.deb

wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.34-lucid/linux-headers-2.6.34-020634-generic_2.6.34-020634_i386.deb
dpkg -i linux-headers-2.6.34-020634-generic_2.6.34-020634_i386.deb

wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.34-lucid/linux-image-2.6.34-020634-generic_2.6.34-020634_i386.deb
dpkg -i linux-image-2.6.34-020634-generic_2.6.34-020634_i386.deb



In next step we shall install dependencies and compile latest package from the git core

sudo apt-get -y install libusb-dev xorg-dev xserver-xorg-video-displaylink git-core
cd ~/Desktop
mkdir libdlo
cd libdlo
wget http://people.freedesktop.org/~berniet/libdlo-0.1.2.tar.gz
tar -xzpf libdlo-0.1.2.tar.gz
cd libdlo-0.1.2
./configure
sudo make install


Now is time to edit /etc/gdm/Init/Default file. Insert following lines of code in the file where the gdmwhich() function ends


XRANDR=`gdmwhich xrandr`
if [ "x$XRANDR" != "x" ] ; then
$XRANDR -o 0
fi


Now comes the most tricky and important step of rewriting your /etc/X11/xorg.conf file.
Most importantly backup your existing xorg.conf file so that you can recover from a crash


sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.orig


Once this is achieved, I suggest that you replace contents from /etc/X11/xorg.conf file with this

Section "ServerLayout"
Identifier "touchscreen"
Screen 0 "DisplayLinkScreen" 0 0
EndSection

Section "Files"
ModulePath "/usr/lib/xorg/modules"
ModulePath "/usr/local/lib/xorg/modules"
EndSection

Section "Device"
Identifier "DisplayLinkDevice"
Driver "displaylink"
Option "fbdev" "/dev/fb0
EndSection

Section "Monitor"
Identifier "DisplayLinkMonitor"
EndSection
Section "Screen"
Identifier "DisplayLinkScreen"
Device "DisplayLinkDevice"
Monitor "DisplayLinkMonitor"
SubSection "Display"
Depth 16
Modes "800x480"
EndSubSection
EndSection


Connect your monitor and reboot your PC. You should be able to see the GDM greeter on your usb display. If you have reached till here, you are doing fine. In case gdm crashes, it is most probably due to two reasons firstly junk characters pasted or wrong frame-buffer device path.
Presently /dev/fb0 works for me. If you suspect this change this to /dev/fb1. You can find the framebuffer devices installed by simply doing ls /dev/fb*.

Assuming that you are on track till here. Drop to another virtual console. We shall revert back to our original file which we have backed up and backup the existing configuration


cd /etc/X11/
sudo mv xorg.conf xorg.conf.fingervu706
sudo cp xorg.conf.orig xorg.conf
sudo service gdm stop
sudo service gdm start


Now you shall have a black screen on your USB monitor and gnome desktop on VGA/DVI display
Following steps need a bit of trial and error and understanding of xorg.conf file directives. I am posting contents of three files.
My original xorg.conf.orig file
FingerVU config file xorg.conf.fingervu706
and lastly and most importantly, my working merged xorg.conf file merging directives from both the files above

xorg.conf.orig

############ Original Video Settings ###########
Section "Screen"
Identifier "Default Screen"
DefaultDepth 16
EndSection

Section "Module"
Load "glx"
EndSection

Section "Device"
Identifier "Default Device"
Driver "nvidia"
Option "NoLogo" "True"
EndSection


xorg.conf.fingervu706

Section "ServerLayout"
Identifier "touchscreen"
Screen 0 "DisplayLinkScreen" 0 0
EndSection

Section "Files"
ModulePath "/usr/lib/xorg/modules"
ModulePath "/usr/local/lib/xorg/modules"
EndSection

Section "Device"
Identifier "DisplayLinkDevice"
Driver "displaylink"
Option "fbdev" "/dev/fb0
EndSection

Section "Monitor"
Identifier "DisplayLinkMonitor"
EndSection
Section "Screen"
Identifier "DisplayLinkScreen"
Device "DisplayLinkDevice"
Monitor "DisplayLinkMonitor"
SubSection "Display"
Depth 16
Modes "800x480"
EndSubSection
EndSection


Merged and working xorg.conf file


############ Original Video Settings ###########
Section "Screen"
Identifier "Default Screen"
DefaultDepth 16
EndSection

Section "Module"
Load "glx"
EndSection

Section "Device"
Identifier "Default Device"
Driver "nvidia"
Option "NoLogo" "True"
EndSection
################################################
Section "ServerLayout"
Identifier "DualDisplay"
Screen 0 "DisplayLinkScreen" 0 0
Screen 1 "Default Screen" LeftOf "DisplayLinkScreen"
EndSection
Section "Files"
ModulePath "/usr/lib/xorg/modules"
ModulePath "/usr/local/lib/xorg/modules"
EndSection

Section "Device"
Identifier "DisplayLinkDevice"
Driver "displaylink"
Option "fbdev" "/dev/fb0
EndSection

Section "Monitor"
Identifier "DisplayLinkMonitor"
EndSection
Section "Screen"
Identifier "DisplayLinkScreen"
Device "DisplayLinkDevice"
Monitor "DisplayLinkMonitor"
SubSection "Display"
Depth 16
Modes "800x480"
EndSubSection
EndSection


Some Pictures of my rig



References and Thanks to

http://karuppuswamy.com/wordpress/2010/07/19/how-to-get-lilliput-displaylink-based-usb-monitor-um-70-17e902a9-working-in-ubuntu-linux/
http://libdlo.freedesktop.org/wiki/
http://ubuntuforums.org/archive/index.php/t-1493143.html
http://mulchman.org/blog/?tag=displaylink