Hi, as a bit of background, My Uni have lately implemented a CGI script so you have to log in to be able to use the wireless. This would be OK but they are terrible programmers and instead of timing out after a period of inactivity it will time out after 570 seconds. Again I wouldn't mind this but to re-connect I have to completely disconnect from the wireless, this is just a pain.
This problem can be overcome by signing out after a period of time and re-signing in. I have written a basic script so far which uses Lynx to open the CGI and sign you in, but, I am having a problem ending the script once run.
I am thinking about calling the script from a second script, passing the process id back and killing it from the first script.
You will find my code below, if anyone knows a better way of doing this or thinks it isn't worth bothering with then please let me know.
Cheers,
Daryll
#!/bin/bash
##########################################################
# Truro Wireless Login (c) D P Doyle 20100421 V1.0
##########################################################
# Description: A script to keep a user logged in whilst
# running the script
# Syntax:
# External shell functions called by script
##########################################################
# Optional notes:
#
##########################################################
# History
# 20100421
clear
if [ ! -e input ]; then
echo "Enter username:"
read USERNAME
s=$USERNAME
echo "# Command logfile created by Lynx 2.8.7pre.6 (23 Jun 2009)
# Arg0 = lynx
# Arg1 = -cmd_log=input
# Arg2 = -exec
# Arg3 = http://172.21.254.254/modules/auth/cgi-bin/ssllogin/login.cgi
key Down Arrow
key Down Arrow
key Down Arrow
key Down Arrow" > "input"
for i in $(seq 0 $((${#s} - 1))); do
echo "key ${s:$i:1}" >> "input"
done
printf "key <tab>\n" >> input
echo "Enter password:"
read PASSWORD
s=$PASSWORD
for i in $(seq 0 $((${#s} - 1))); do
echo "key ${s:$i:1}" >> "input"
done
printf "key ^J
key ^J
key y" >> input
fi
lynx -cmd_script=input -exec 'http://172.21.254.254/modules/auth/cgi-bin/ssllogin/login.cgi'
exit
How I am trying to do it at the moment.
lynx 'http://localhost'
source test1.sh &
DAR=$!
echo 'Running in background...'
sleep 5
echo 'Quitting...'
kill $DAR
return