2

i am currently trying to write a script to change some parameters on a webpage via a shell script. I can change the values in the textboxes without any problems, but i can't seem to figure out how i can "press" the Apply button.

This is how i change the values, as you can see i need one final "Apply" button press.

setJitterDelay()
{
    rate=${1}
    if [ "${rate}" == "low" ]; then
            ((htmlJitterNegDelta = 5))
            ((htmlJitterPosDelta = 5))
            ((htmlJitterDelayMax = 10))
            jDelta=5
    else
            if [ "${rate}" == "med" ]; then
                    ((htmlJitterNegDelta = 25))
                    ((htmlJitterPosDelta = 25))
                    ((htmlJitterDelayMax = 50))
                    jDelta=25
            else
                    if [ "${rate}" == "high" ]; then
                            ((htmlJitterNegDelta = 50))
                            ((htmlJitterPosDelta = 50))
                            ((htmlJitterDelayMax = 100))
                            jDelta=50
                    else
                            echo "error: low, med, high not selected! Skipped..."
                            return
                    fi
            fi
    fi
    ### APPLY BUTTON
}

I used Firebug to know which values i had to change and the Apply button says this:

  <input id="appFlowBw" type="submit" value="Apply" name="appFlowBw">
<form action="http://wanemu/XGEM_REV_BW_FLOW?blade=1&profile=0" method="post" name="rev_bw_form"></form>

The input is inside the form in the source code:

             <TR>
          <TD colspan="8"></TD>
          <TD><INPUT type="submit" name="appFlowBw" id="appFlowBw" value="Apply" disabled></TD>
      </FORM>

But i don't know how i can now "press" this button.

I hope you understand my problem and can help.

//edit: added form

  • Could you please also post the form? Do you know what method it's using to submit the data? – replay Aug 30 '13 at 8:26
  • @mauro.stettler added above if thats what your looking for. Sorry i am a newbie when it comes to these. – Shabu Aug 30 '13 at 8:38
  • is the <input> tag really outside the <form></form> or is this just copy pasted wrong? – replay Aug 30 '13 at 8:47
  • @mauro.stettler Bad copied i guess. The input tag is in a big <form> tag with all the <td> and <tr>. In Firebug it was just shown at the end. Edited the above again for format reasons – Shabu Aug 30 '13 at 8:51
6

Pressing this button will only cause the browser to submit a POST request to the server, together with all the values of the according form as payload in the body of the request.

So if you want the effect of this click reproduced in a shell script, what you have to do is to build your data in the format it's passed in a POST request, and then submit a POST to the server to emulate the pressing of the button.

It should be quite easy to do this with curl, just like described here: What is the cURL command-line syntax to do a POST request?

Example:

curl --data "param1=value1&param2=value2" http://example.com/resource.cgi
  • How do you know the form uses POST method? Maybe that form submits to a “JavaScript required” error page and the real transfer is done through AJAX. – manatwork Aug 30 '13 at 8:24
  • @manatwork just asked him to post the form or details about how the data is submitted – replay Aug 30 '13 at 8:25
  • 1
    @manatwork Now we know it's a POST, he added the form – replay Aug 30 '13 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.