Jump to content

How to get the output of one command to the end of another


ImmobileBlock

Recommended Posts

I'm put together a shell script to change a mac address and login to a wifi hotspot. I already have one from a while ago

#!/bin/bash
rfkill block wifi
sleep 1
macchanger wlan0 -r
sleep 1
rfkill unblock wifi
sleep 10
iceweasel xfinity.com
sleep 5
xdotool key Tab
xdotool key Tab
xdotool key Tab
xdotool key Tab
xdotool key Tab
xdotool key Tab
xdotool key Tab
xdotool key Tab
xdotool key KP_Enter
sleep 6
xdotool key Tab
xdotool key Up
xdotool key Tab
xdotool key Tab
xdotool key Tab
xdotool key 1
xdotool key 2
xdotool key 3
xdotool key 4
xdotool key 5
xdotool key Tab
xdotool key x
xdotool key f
xdotool key i
xdotool key n
xdotool key i
xdotool key t
xdotool key y
xdotool type @
xdotool key g
xdotool key m
xdotool key a
xdotool key i
xdotool key l
xdotool type . 
xdotool key c
xdotool key o
xdotool key m
xdotool key Tab
xdotool mousemove 458 705 click 1
xdotool key Tab
xdotool key Tab
sleep 1
xdotool key KP_Enter

it pulls up iceweasel then uses xdotool to navigate the page to login. I think I can speed it up and have it run totally in the background using w3m. The home page of the router uses your mac address to generate the "signup link" the link ends up looking something like "https://cable.nnu.com/cablewifi/?client-mac=00:00:00:00:00:00". because I know the structure of what the"signup link" will be I should be able to navigate straight to the to "signup" page and cut out the home page to save time. because I'm using this with macchanger the mac address wont be a constant and is randomly generated.

I know that

cat /sys/class/net/wlan0/address

can get me my current mac

how to I get that output to replace the mac in this code

w3m https://cable.nnu.com/cablewifi/?client-mac=00:00:00:00:00:00 

how do I get the output of one command to the end of another? I saw people using pipes "|" to move the output to the input of other commands. I feel like that's what I'm trying to do but I cant put them together correctly . Is there a better way? I do foresee another problem after this one. I use xdotool to automate the signup for the hotspot right now. When I'm using w3m in a shell in the background xdotool wont work because it acts like keyboard input so it wont affect the shell in the background that's a problem for another day. I just dont know what I should get to know to make this work, ya know?

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

OKay so where im at now. w3m does not seem to be the way to go. curl looks like it can do exactly what I need from the next step, but im having issues with how to write a bash script to fill in the page.

this it the page sorce code






<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>XFINITY WiFi</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="/xfinitywifi/media/images/favicon.ico">
<link href="/xfinitywifi/media/styles/reset.css" rel="stylesheet" type="text/css">
<link href="/xfinitywifi/media/styles/ppu.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/xfinitywifi/media/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/xfinitywifi/media/js/main.js"></script>
<script type="text/javascript" src="/xfinitywifi/media/js/errors.js"></script>
<script type="text/javascript">
var basepath = '/xfinitywifi/';
</script>

<link rel="stylesheet" href="/xfinitywifi/media/js/fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen">
<script type="text/javascript" src="/xfinitywifi/media/js/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript" src="/xfinitywifi/media/js/purchase.js"></script>
<script type="text/javascript" src="/xfinitywifi/media/js/cookie.js"></script>
<script type="text/javascript" src="/xfinitywifi/media/js/login.js"></script>
<script type="text/javascript">
var actionurl = basepath + 'signup';
var portalpage = 'ppu';
var referpage = 'offer';
var planid = '14555';
var do_reg = ['spn'];
var autorenew_plans = ['14557', '15478'];

$(document).ready(function(){
set_browser_info();
});
</script>

</head>
<body>

<div id="wrapper">
<div id="header">
<img src="/xfinitywifi/media/images/Header/Logo.png" width="77" height="45" alt="xfinity" />
</div>

<div id="contentContainer">
<img src="/xfinitywifi/media/images/logo-xfinity-wifi-3.png" width="259" height="56" alt="xfinity wifi" id="wifiLogo" />

<div id="redBox">

<p>
Try out XFINITY WiFi!
</p>

<p>

Purchase an Access Pass or use a complimentary session.
</p>


</div>

<div id="mainBox" class="box">
<h2>Get Access Now</h2>

<div id="content">







<form id="purchaseForm" name="purchaseForm" action="/xfinitywifi/signup" method="post" accept-charset="utf-8" onsubmit="dummy()">
<div>

<select name="rateplanid" id="rateplanid">
<option value="spn">$0.00 for a Complimentary Hour Pass</option>
<option value="14555">$2.95 for an Hour Pass</option>
<option value="14556">$7.95 for a Day Pass</option>
<option value="14557">$19.95 for a Week Pass</option>
<option value="15478">$54.95 for a 30 Day Pass</option>
</select>


<div id="learnlink">
<a href="http://www.comcast.com/wifi"class="logclick pop">Learn More about XFINITY WiFi</a>
</div>
<div id="offerlink">
<a href="/xfinitywifi/terms" class="pop">Offer and Restrictions</a>
</div>



<div id="messageBox">
<!-- Common fields -->
<li style="display:none"><label for="username" class="error" style="display:block"></label></li>
<li style="display:none"><label for="password" class="error" style="display:block"></label></li>
<li style="display:none"><label for="password1" class="error" style="display:block"></label></li>
<li style="display:none"><label for="password2" class="error" style="display:block"></label></li>
<li style="display:none"><label for="firstname" class="error" style="display:block"></label></li>
<li style="display:none"><label for="lastname" class="error" style="display:block"></label></li>
<li style="display:none"><label for="email" class="error" style="display:block"></label></li>

<!-- For payment forms -->
<li style="display:none"><label for="cardnumber" class="error" style="display:block"></label></li>
<li style="display:none"><label for="expmm" class="error" style="display:block"></label></li>
<li style="display:none"><label for="ccv" class="error" style="display:block"></label></li>
<li style="display:none"><label for="billstate" class="error" style="display:block"></label></li>
<li style="display:none"><label for="billcountry" class="error" style="display:block"></label></li>
<li style="display:none"><label for="billpostal" class="error" style="display:block"></label></li>


<!-- For sponsored access registration -->
<li style="display:none"><label for="spn_postal" class="error" style="display:block"></label></li>
<li style="display:none"><label for="spn_email" class="error" style="display:block"></label></li>
<li style="display:none"><label for="spn_terms" class="error" style="display:block"></label></li>

<li style="display:none"><label for="userpass" class="error" style="display:block"></label></li>
<li style="display:none"><label for="process" class="error" style="display:block"></label></li>
</div>


<div id="complimentary_spn">
<div class="formLabel">
<label for="spn_postal">Zip Code</label>
</div>
<div class="formInput">
<input type="text" id="spn_postal" name="spn_postal" value="">
</div>

<div class="formLabel">
<label for="spn_email">Email</label>
</div>
<div class="formInput">
<input type="text" id="spn_email" name="spn_email" value="">
</div>

<div class="checkBox">
<input type="checkbox" id="spn_terms" name="spn_terms" value="1" style="float:left;margin-right:5px">
<div style="padding-top:5px"><label for="spn_terms">I have read and agree to the <a href="http://www.comcast.com/wifi/nonmemberwifiterms.html"class="logclick pop">Terms of Service</a> and to receive promotional emails from Comcast</label></div>
</div>

<div id="ccBtns">
<input type="button" name="" value="submit" class="startSessionButton submit">
<div class="clear"></div>
</div>

<p>All fields mandatory. Information is used to provide you with information about XFINITY services. You can unsubscribe at any time.</p>

</div>

<div id="paid">
<div id="intro">
<h3>Restrictions:</h3>
<ol>
<li>Access Pass is usable only on your current device.</li>
<li>Access Pass is not for use on Comcast roaming partner hotspots.</li>
</ol>
</div>

<h3>Create a New XFINITY WiFi Access Pass Account</h3>
<p>(<a href="/xfinitywifi/renew/form">Already an XFINITY WiFi Access Pass customer?</a>)</p>

<p>All fields mandatory</p>
<div class="formLabel">
<label for="username">Access Pass Username</label>
</div>
<div class="formInput">
<input type="text" id="username" name="username" value="">
</div>

<div class="formLabel">
<label for="password1">Access Pass Password</label>
</div>
<div class="formInput">
<input type="password" id="password1" name="password1" value="">
</div>

<div class="formLabel">
<label for="password2">Confirm Access Pass Password</label>
</div>
<div class="formInput">
<input type="password" id="password2" name="password2" value="">
</div>

<h3>Contact Information</h3>
<div class="formLabel">
<label for="firstname">First Name</label>
</div>
<div class="formInput">
<input type="text" id="firstname" name="firstname" value="">
</div>

<div class="formLabel">
<label for="lastname">Last Name</label>
</div>
<div class="formInput">
<input type="text" id="lastname" name="lastname" value="">
</div>

<div class="formLabel">
<label for="email">Email</label>
</div>
<div class="formInput">
<input type="text" id="email" name="email" value="">
</div>





<div id="paymentInfo">
<div id="paymentInfoLbl">Payment Information</div>
<div id="paymentCards"><span id="accept">We accept:</span> <img id="ccs" src="/xfinitywifi/media/images/Icons/CC.png" width="135" height="23" alt="credit cards"></div>
<div class="clear"></div>
</div>

<div id="paymentFormLbl1">
<div>
<div id="numberLbl">
<label for="cardnumber">Number</label>
</div>
<div id="ccvLbl" >
<label for="ccv">CVC</label>
</div>
<div id="expLbl">
Expiration
</div>
<div class="clear"></div>
</div>

<div id="paymentFormInputs1">
<input type="text" id="cardnumber" name="cardnumber" value="">
<input type="text" id="ccv" name="ccv" value="" maxlength="4">
<img src="/xfinitywifi/media/images/Icons/Lock.png" width="14" height="18" alt="lock" id="lock">

<div id="mthLbl">
<label for="expmm">Month</label>
</div>
<select id="expmm" name="expmm">



<option value="01" >1</option>




<option value="02" >2</option>




<option value="03" >3</option>




<option value="04" selected="selected">4</option>




<option value="05" >5</option>




<option value="06" >6</option>




<option value="07" >7</option>




<option value="08" >8</option>




<option value="09" >9</option>




<option value="10" >10</option>




<option value="11" >11</option>




<option value="12" >12</option>

</select>

<div id="yearLbl">
<label for="expyy">Year</label>
</div>
<select id="expyy" name="expyy">
<option value="16">2016</option>
<option value="17">2017</option>
<option value="18">2018</option>
<option value="19">2019</option>
<option value="20">2020</option>
<option value="21">2021</option>
<option value="22">2022</option>
<option value="23">2023</option>
<option value="24">2024</option>
<option value="25">2025</option>
<option value="26">2026</option>
<option value="27">2027</option>
<option value="28">2028</option>
<option value="29">2029</option>
<option value="30">2030</option>
</select>

<div class="clear"></div>
</div>

<div id="paymentFormLbl2">
<div id="ccCountryLbl">
<label for="billcountry">Country</label>
</div>
<div id="ccStateLbl">
<label for="billstate">State</label>
</div>
<div id="ccZipLbl">
<label for="billpostal">ZIP/Postal Code</label>
</div>
<div class="clear"></div>
</div>

<div id="paymentFormInputs2">
<div id="ccCountry">
<select name="billcountry" id="billcountry" onchange="update_state()">
<option value="">Select a Country</option>
<option value="US">United States of America</option>
<option value="CA">Canada</option>
</select>
</div>

<select name="billstate" id="billstate" onchange="update_country()">
<option value="">Select a State</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AB">Alberta</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="AA">Armed Forces - Americas (except Canada)</option>
<option value="AE">Armed Forces - Europe, Canada, Middle East, Africa</option>
<option value="AP">Armed Forces - Pacific</option>
<option value="BC">British Columbia</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MB">Manitoba</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NB">New Brunswick</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NL">Newfoundland</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="NT">Northwest Territories</option>
<option value="NS">Nova Scotia</option>
<option value="NU">Nunavut</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="ON">Ontario</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="PE">Prince Edward Island</option>
<option value="PR">Puerto Rico</option>
<option value="QC">Quebec</option>
<option value="RI">Rhode Island</option>
<option value="SK">Saskatchewan</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
<option value="YT">Yukon</option>
</select>

<input type="text" id="billpostal" name="billpostal" value="">
<div class="clear"></div>

<div class="checkBox">
<input type="checkbox" id="storeinfo" name="storeinfo" value="1"> <label for="storeinfo">Store my payment information.</label>
</div>
<div class="checkBox" id="autorenew_container" style="display:none">
<input type="checkbox" id="autorenew" name="autorenew" value="1" disabled="disabled">
<label for="autorenew">Automatically renew my Access Pass upon expiration</label>
</div>
</div>
</div>

<div id="ccBtns">
<input type="button" name="" value="submit" class="submitOrderButton submit">
</div>
<div class="disclaimer">
By clicking on "Continue" you are confirming your XFINITY WiFi Access Pass purchase and will be billed the appropriate fees based upon the Access Pass you've selected.
By signing up as an XFINITY WiFi Access Pass customer, you agree to the <a href="http://www.comcast.com/wifi/nonmemberwifiterms.html"class="logclick pop">XFINITY WiFi Terms of Service</a>.
</div>

</div>
</div>
</form>

<div id="popups">
<a href="#completePopup" id="triggerComplete"></a>
<div id="completePopup"></div>
</div>

</div>
</div>

<div id="xsubad" class="boxNoHeader">
<p><strong>XFINITY Internet subscribers</strong> have access to thousands of WiFi hotspots around town every day. Call 1-800-XFINITY for home Internet plans starting as low as $29.99 and get XFINITY WiFi included for <strong>no additional charge!</strong></p>
</div>

<div id="needHelp">

<a href="https://wifilogin.comcast.net/wifi/start.php?bn=st01&tm=xfw01&cm=$(cat/sys/class/net/wlan0/address)">XFINITY Internet or Business Class Customer?</a>
<br><br>
Need Help? Contact 1-866-366-5756

</div>
<div class="clear"></div>
</div>

<div class="disclaimer">
Not available in all areas. XFINITY WiFi is only included with XFINITY Internet Performance (or above) service. Requires compatible WiFi-enabled laptop or mobile device. Hotspots available in select locations only. May not be combined with other offers. Pricing and services, subject to change. Call for restrictions and complete details or visit <a href="http://comcast.com/wifi"class="pop">comcast.com/wifi</a>.
</div>
</div>

<div id="footerContainer">




<div class="footerLinks">
<span class="logo"></span>
<a href="http://www.comcast.com/corporate/legal/privacyStatement.html"class="logclick pop">Privacy Statement</a>
<span>|</span>
<a href="http://www.comcast.com/wifi/comcastwifiAUP.html"class="logclick pop">Acceptable Use Policy</a>
<span>|</span>
<a href="http://www.comcast.com/wifi/nonmemberwifiterms.html"class="logclick pop">Terms of Service</a>
<span>|</span>
<span>© 2016 Comcast</span>
</div>

</div>

<div class="pleasewait"></div>


</body>
</html>

I need to fill in the"rateplanid" as "spn" the free option, the "spn_postal" should be something generic like "55555", the "spn_email" needs to be generic as well "xfinity@xfinity.com", the "spn_terms" needs to be checked, then all thats left is to submit.

As I said before all this seems like curl would be the correct choice. where would the best place to find totorial for curl be? there area few videos online but they seem to be over my head.

Link to comment
Share on other sites

  • 2 weeks later...

yeah there was suppose to be a space there, you are correct, I'm constantly plagued with formatting issues when I post here (and everywhere actually) because I try to do everything with JavaScript disabled. It make surfing the web very interesting and fun.

Edit: I concur, you could probably get more info with a proxy of some sort. If you have access to a firefox browser, theres an addon that I've used in the past called "Live HTTP Headers" that will be able to pick up all the header info, along with all the get and post variables for the requests to every resource on that site. I wouldn't run that addon for daily use because it might also reveal passwords and things you want to protect. But it will show you all the post variables that will end up in the request.

form id="purchaseForm" name="purchaseForm" action="/xfinitywifi/signup" method="post" accept-charset="utf-8" onsubmit="dummy()"

I'm guessing that the header your looking for begins with "POST /xfinitywifi/signup HTTP/1.1"

PPS: I think you might have the wrong webpage, this looks like a signup webpage and not a signin webpage

Edited by fugu
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...