Q:

Load website and fill form from the command line

Using the Linux command line (Bash shell) I like to load a specific website in my browser (normally Firefox, but other one would be ok as well as long it runs under Linux) and fill a pre-defined form with some data. Actually, this should run from a Makefile. Most of the form data is static and will be stored as variables in the Makefile, just some fields are to be filled manually before manually sending the form.
I know how to load the website in question from the command line using:
firefox <URL>

But there seems no possibility to fill the form automatically with variables given on the command line. Is there a plugin, executable or JavaScript which allows me to do this? Any suggestions and hints are welcome. I don't mind coding some JavaScript.

A:

See https://github.com/bard/mozrepl/wiki.  MozRepl lets you connect via telnet, in combination with netcat this would be exactly what you need.

A:

I solved this now using a Greasemonkey script which copies the URL parameters to the form.
The Makefile calls firefox with the URL including the parameters.
This works for my needs. Some refinements would be needed for more complex input, i.e. some URL encoding.
User Script:
// ==UserScript==
// @name           Fill CTAN upload form
// @namespace      http://www.scharrer-online.de/namespace/
// @description    Fills the CTAN upload form with the data provided as URL variables
// @include        http://*.ctan.org/upload.html*
// @require        http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// ==/UserScript==

//var $ = unsafeWindow.jQuery;

// From http://papermashup.com/read-url-get-variables-withjavascript/
// Added: decodeURI
function getUrlVars() {
    var vars = {};
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = decodeURI(value);
    });
    return vars;
}

var vars = getUrlVars();

for (name in vars) {
    $("input[name=" + name + "]").val(vars[name]);
    $("select[name=" + name + "]").find("option:selected").removeAttr('selected');
    $("select[name=" + name + "]").find("option[value=" + vars[name] + "]")
            .attr('selected','selected');
}

if ('DoNotAnnounce' in vars) {
    var val = vars['DoNotAnnounce'].toLowerCase();
    if (val == '1' || val == 'yes' || val == 'true') {
        $("input[name=DoNotAnnounce]").attr('checked','checked');
    }
}

Makefile:
# CTAN Upload
CTAN=http://dante.ctan.org/upload.html
CONTRIBUTION=filemod
VERSION=
NAME=John Doe
EMAIL=john.doe@somewhere.com
SUMMARY=Updated to ${VERSION}:
DIRECTORY=/macros/latex/contrib/${CONTRIBUTION}
DONOTANNOUNCE=
ANNOUNCEMENT=
NOTES=
LICENCE=free
FREEVERSION=lppl
#FILE= # can't be set because of security limitations

upload: ctanify
    firefox 'http://dante.ctan.org/upload.html?contribution=${CONTRIBUTION}&version=${VERSION}&name=${NAME}&email=${EMAIL}&summary=${SUMMARY}&directory=${DIRECTORY}&DoNotAnnounce=${DONOTANNOUNCE}&announce=${ANNOUNCEMENT}&notes=${NOTES}&license=${LICENCE}&freeversion=${FREEVERSION}' &

