Okay .. here's my silly way of creating a fortune powered webpage (here i'm
using Optushome - no perl/php/asp/.bat there :).
My goal was to get the text from one fortune cookie (fortune binary) and
upload it to my optushome web page.
It consists of three things,
+ ncftpput (these command line options used to be in ncftp itself) to upload
the index.html file I create.
+ lynx, to check the stuff with -source (actually it logs it here)
+ a shell script to create the index.html and finally call lynx/ncftpput.
Here's the script (with false log/passes)
#!/bin/sh
# The first redirection uses a > to overwrite the index.html
# So you dont have several fortunes
# After this it uses >> to append
echo "<html><head><title>" > index.html
echo >> index.html
# You get your own TITLE ! :)
echo "Title Here" >> index.html
echo >> index.html
echo "</title></head>" >> index.html
echo >> index.html
# When it comes to unix users, <pre> doesnt look all that shabby :)
# It prevents the whole fortune from appearing on the same line
echo "<body bgcolor=white><p> </p><p> </p><blockquote><pre>" >>
index.html
echo >> index.html
date >> index.html
echo >> index.html
echo >> index.html
# The fortune g3nerat0r ! >8[
fortune >> index.html
echo >> index.html
echo "</pre></blockquote></body>" >> index.html
# note that -V makes it silent .. muahaha >8[
# SimpleSyntax™
# ncftp -u mylogin -p mypass host.com /rootdir file1 file2
ncftpput -V -u mylogin -p mypass members.optushome.com.au / index.html
# You can log the stuff on the page now to a file
lynx -source http://members.optushome.com.au/kozer/ >> log.txt
# This is a really neat option !
# I *could* -source slashdot.org and redirect it to slashdot.html
# See http://members.optushome.com.au/slashdot.html :)
# okay this is getting silly :)
# Log the stuff if you want
echo >> log.txt
echo "-----------------------------" >> log.txt
echo >> log.txt
then
chmod +x ftpgo
then ./ftpgo
This script is actually quite interesting, you could:
echo "My Linux Box has the qualities: " >> index.html
date >> index.html
uname -a >> index.html
uptime >> index.html
in there if you wanted to (uptimes - you know you want to :)
Or echo some other stuff .. like err err .. I dont know, maybe something
else on your hard drive. Webcam images ? :
ncftpput -V -u mylog -p my pass members.optushome.com.au / index.html
myroom.jpg
You could add something to the cron to make it run hourly (or whatever) .. I
tried a ln -s from the cron.hourly directory but it didnt work ;) ...
oh yeh, would it be sensible to create a never ending perl script with
sleep(60)s in it that starts on boot and calls the script with
`/home/usermatt/ftpgo` ?
Done ! You can see how it turns out at :
http://members.optushome.com.au/kozer/
This is MY way of doing this, it's probably doable in one regular expression
or somethin silly :) but uhmm ... tell me how such a script could be done
with less code ?
Regards, Matt
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text