Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

share|improve this question
 
Could you please also post the form? Do you know what method it's using to submit the data? –  mauro.stettler 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? –  mauro.stettler 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
add comment

1 Answer

up vote 4 down vote accepted

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
share|improve this answer
 
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 –  mauro.stettler Aug 30 '13 at 8:25
 
@manatwork Now we know it's a POST, he added the form –  mauro.stettler Aug 30 '13 at 8:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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