I have a ISP that randomly logs me out and my connection gets lost.So i want to write a script that automatically logs me in without user interaction when logged out (which i can test using a ping exit status).But the problem is i don't know anything about web programming.I tried curl but cant figure stuff out.Tried elinks but it does not work as a script or as a cronjob without user interaction
what i have tried so far
cat ~/bin/elink
elinks -auto-submit http://192.168.1.2:9088/WISHN/Login.jsp
by running this command it auto logs me in (by editing ~/.elinks/elinks.conf)
but it just stays there untill user interacts and exits the app but pressing "q"
thats why this script does not work
#!/bin/bash
while [ 1 -eq 1 ]
do
. ~/bin/elink
slleep 3
pkill-9 elinks
sleep 5
done
the next command does not run untill elinks exits
timeout 1m elinks -auto-submit http://192.168.1.2:9088/WISHN/Login.jsp
this does not works too nothing happens
I tried these with curl but as usual does not work
curl -d "Username=someuser&Password=shhhitsasecret" -s http://192.168.1.2:9088/WISHN/loginUI.do2
and this
curl -d "Username=someuser&Password=shhhitsasecret" -s http://192.168.1.2:9088/WISHN/Login.jsp
i found the loginUI.do2 in the action section of the source but it fails too
im pretty much empty of ideas any help will be very apreciated
and here is the source of the page i have deleted some parts that could result in privacy violation
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<title>somewebsite</title>
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="stylesheet/styles.css" />
<link rel="stylesheet" type="text/css" href="stylesheet/style_pop.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/custom.js"></script>
<!--
<script language="javascript" type="text/javascript">
function clearText(field)
{
if (field.defaultValue == field.value) field.value = '';
else if (field.value == '') field.value = field.defaultValue;
}
</script>-->
<script language="JavaScript">
function newCookie(Username,value,days) {
var days = 30; // the number at the left reflects the number of days for the cookie to last
// modify it according to your needs
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString(); }
else var expires = "";
document.cookie = Username+"="+value+expires+"; path=/"; }
function readCookie(Username) {
var nameSG = Username + "=";
var nuller = '';
if (document.cookie.indexOf(nameSG) == -1)
return nuller;
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameSG) == 0) return c.substring(nameSG.length,c.length); }
return null; }
function eraseCookie(Username) {
newCookie(Username,"",1); }
function toMem(a) {
newCookie('theName', document.login.Username.value); // add a new cookie as shown at left for every
newCookie('theEmail', document.login.Password.value); // field you wish to have the script remember
}
function delMem(a) {
eraseCookie('theName'); // make sure to add the eraseCookie function for every field
eraseCookie('theEmail');
document.login.Username.value = ''; // add a line for every field
document.login.Password.value = ''; }
function remCookie() {
document.login.Username.value = readCookie("theName");
document.login.Password.value = readCookie("theEmail");
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function() {
remCookie();
});
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
if ((version >= 5.5) && (document.body.filters))
{
for(var i=0; i<document.images.length; i++)
{
var img = document.images[i]
var imgName = img.src.toUpperCase()
if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
{
var imgID = (img.id) ? "id='" + img.id + "' " : ""
var imgClass = (img.className) ? "class='" + img.className + "' " : ""
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
var imgStyle = "display:inline-block;" + img.style.cssText
if (img.align == "left") imgStyle = "float:left;" + imgStyle
if (img.align == "right") imgStyle = "float:right;" + imgStyle
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
var strNewHTML = "<span " + imgID + imgClass + imgTitle
+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
img.outerHTML = strNewHTML
i = i-1
}
}
}
}
/* ------- Trim ------- */
function trim(str) {
return ltrim(rtrim(str));
}
function ltrim(str) {
return str.replace(new RegExp("^[\\s]+", "g"), "");
}
function rtrim(str) {
return str.replace(new RegExp("[\\s]+$", "g"), "");
}
/* ------- End of Trim ------- */
function validateForm(){
var input=true;
document.login.Username.value = trim(document.login.Username.value);
if(document.login.Username.value.length==0){
alert("User Name is required.");
document.login.Username.focus();
input=false;
return false;
}
if(document.login.Password.value.length==0){
alert("Password is required.");
document.login.Password.focus();
input=false;
return false;
}
var uname = "?"+document.login.Username.value+"+/@";
var pwd = "?"+document.login.Password.value+"+/@";
document.login.LoginName.value=encodeURIComponent(uname);
document.login.LoginPassword.value=encodeURIComponent(pwd);
if (input==true&&document.login.checker.checked)
toMem(this);
}
window.attachEvent("onload", correctPNG);
</script>
</head>
<!--Main Container Starts here-->
<form name="login" method="post" action="loginUI.do2" onSubmit="if (this.checker.checked) toMem(this)" id="login-form">
<body>
<div id="templatemo_wrapper">
<div id="templatemo_menu">
<marquee scrollamount="3" behavior="slide" direction="left" height="20" width="100%" style="color:#00162b"><p> Your Default Password is <strong style="color:#FFFFFF">wnpl123</strong> for first time login only. Please change your password after first login.</p></marquee>
</div> <!-- end of templatemo_menu -->
<div id="templatemo_header_bar">
<div id="header"><!--<div class="right"></div>-->
<h1><a href="#">
<img src="images/templatemo_logo.png" alt="Site Title" width="254" />
<span> </span>
</a></h1>
</div>
<div style=" font-size:22px; color:#000; margin-top:50px; float:right; font-family:Arial, Helvetica, sans-serif; left: 878px; top: 0px; width: 285px;">
Toll Free : 1800 419 4244 </div>
</div> <!-- end of templatemo_header_bar -->
<div class="cleaner"></div>
<div id="sidebar"><div class="sidebar_top"></div><div class="sidebar_bottom"></div>
<div class="sidebar_section">
<h2>Login Form</h2>
<div style="color:#FFFF00; font-size:12px; margin-top:45px; margin-bottom:10px;"><b>
</b></div>
<label>Username</label>
<input type="text" name="Username" size="20" class="input_field" />
<label>Password</label>
<input type="password" value="" name="Password" class="input_field" title="password" />
<input type="hidden" name="LoginName" />
<input type="hidden" name="LoginPassword" />
<label for="checkbox"><br><input type="checkbox" name="checker" id="checker" /> Remember Me</label>
<br />
<input type="submit" value="Login" id="submit_btn" onClick="return validateForm()" />
</div>
</div> <!-- end of sidebar -->
<div id="templatmeo_content">
<div id="latest_product_gallery">
<img src="images/bannerr.png" />
<a href="index1.html" target="_blank"> <div class="intro-texttt" align="right"></div>
</a>
</div> <!-- end of latest_content_gallery -->
</div>
Z<!-- end of templatmeo_content -->
</div> <!-- end of templatemo_wrapper -->
<!--<div class="popupbox3" id="popuprel3">
<div id="intabdiv3" align="left">
<table border="0" align="left">
<tr height="16px"><td></td></tr>
<tr height="16px"><td></td></tr>
<tr><td><h2> Steps to Install:-</h2> </td><tr>
<tr><td><Font color="#000000"><strong>1.</strong> <a href="http://172.18.1.60/gamestore/UrbanTerror.rar" style="color:#0000CC">Download</a> UrbanTerror -> Extract UrbanTerror.rar-></font></td></tr><tr><td><Font color="#000000" > Install UrbanTerror.exe</font></td></tr><tr height="14px"><td></td></tr>
<tr><td><Font color="#000000">
<strong> 2.</strong><b>Play :</b><i>Online </i>|<b>Source :</b><i>Favorites </i>| <b> Type : </b><i>On/All</i></font> </td></tr>
<tr><td><Font color="#000000" >
<b>Create Favourite Name : </b><i>WISH-UT </i></font></td></tr>
<tr><td><Font color="#000000" >
<b> IP Address :</b><i>172.18.1.60 |</i>
<b> Guides: </b><i>On/All</i></font></td></tr>
<tr><td><Font color="#000000">
<b>OK & CONNECT</b></font></td></tr>
</table>
</div>
</div>
-->
<div id="templatemo_footer_wrapper">
<div id="templatemo_footer">
Copyright © 2099 <a href="#">somewebsite</a> |
Designed by <a href="http://www.templatemo.com" target="_parent">Wish Net</a>
</div> <!-- end of footer -->
</div> <!-- end of footer_wrapper -->
<!--<div id="fade"></div>-->
<!--</form>
<script type="text/javascript"> Cufon.now(); </script>-->
</body>
</html>