Of course! Here it is:
Code:
#!/bin/sh
#Disable powersave
echo test > /sys/power/wake_lock
#Activate powersave again at any kind of exit from the script
trap 'echo test > /sys/power/wake_unlock' EXIT
# connect only to network if we're not already connected (from review's rsh.app)
mypid="$(ps |grep netagent|grep connect)"
if [[ "$mypid" == "" ]]; then
/ebrmain/bin/netagent connect
fi
#Download the webpage containing the list of available issues of the newspaper.
#Observe that this version of wget comes from LoneTech's SDK image for the qemu emulator,
#due to the lack of option "--load-cookies" in the built in wget.
/mnt/ext1/system/bin/wget --load-cookies /mnt/ext2/nwtscript/cookies.txt http://www1.nwt.se/script/cgiip.exe/WService=nwt/etidning.html -P /var/tmp &> /dev/null
#Extract only the relevant lines from the webpage
cat /var/tmp/etidning.html | grep 'http://np.netpublicator.com/netpublication' > /var/tmp/lista.txt
#Extract the latest issues id-number
tidnnr=$(awk -F'=' 'NR==1 {print substr($2, 45, 9) }' /var/tmp/lista.txt)
#Extract/compose the filename
filnamn=$(awk -F'=' 'NR==1 {print substr($4, 2, length($4)-3)".pdf" }' /var/tmp/lista.txt)
#Remove file with the same name if there is one
if [ -e /mnt/ext2/$filnamn ]; then
rm /mnt/ext2/$filnamn &> /dev/null
fi
#Download the latest available issue using built in wget
wget http://np.netpublicator.com/np/$tidnnr/$filnamn -P /mnt/ext2 &> /dev/null
# disconnect only from network if we were not connected when script started. (from review's rsh.app)
if [[ "$mypid" == "" ]]; then
/ebrmain/bin/netagent disconnect
fi
#Clean up
rm /var/tmp/lista.txt
rm /var/tmp/etidning.html
Hope some of this will be useful for other PB users!
B.R.
niroma