Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

shell scripting firefox

19 views
Skip to first unread message

dale...@earthlink.net

unread,
Feb 8, 2012, 9:44:23 AM2/8/12
to
Hello,

I am trying to create a bash script that does the following


firefox http://myurl.com/ Ctrl-S ENTER Ctl-Q


in other words I invoke firefox from the command line with the url I
want to go to
then without touching the keyboard,
the Control + S Keys are pressed, Then without touching the
keyboard,
the Enter Key is pressed, Then without touching the
keyboard,
the Control + Q Keys are pressed.

what I am trying to do is to get firefox to act like a big bloated
"wget" command.
this is what I NEED to do.

I cannot figure out how to enter these Control Key Sequences into a
text file,
what does CTL-S look like ^[S or ^S or something else ?
what does ENTER look like ?
also should the command look like this,


firefox http://myurl.com/ | Ctrl-S | ENTER | Ctrl-Q


or should it look like this,


firefox http://myurl.com/ ; Ctrl-S ; ENTER ; Ctrl-Q


or should it be a kind of control loop in bash,


while [ 1 ]
do
firefox http://myurl.com/
Ctl-S
ENTER
Ctl-Q
done

It is a simple idea, but I cannot get it to work.
thank you.

Ben Bacarisse

unread,
Feb 8, 2012, 12:57:27 PM2/8/12
to
dale...@earthlink.net writes:

> I am trying to create a bash script that does the following
>
> firefox http://myurl.com/ Ctrl-S ENTER Ctl-Q
>
> in other words I invoke firefox from the command line with the url I
> want to go to
> then without touching the keyboard,
> the Control + S Keys are pressed, Then without touching the
> keyboard,
> the Enter Key is pressed, Then without touching the
> keyboard,
> the Control + Q Keys are pressed.
>
> what I am trying to do is to get firefox to act like a big bloated
> "wget" command.
> this is what I NEED to do.
>
> I cannot figure out how to enter these Control Key Sequences into a
> text file,
> what does CTL-S look like ^[S or ^S or something else ?
> what does ENTER look like ?

It doesn't matter. Putting the control characters into the file (which
can be done, BTW) won't do what you want. Take this analogy... Assume
there is a new browser called waterrat that uses a plain 's' instead of
Ctrl-S, a plain 'q' instead of Ctrl-q and an 'e' instead of enter.
Putting this into a file:

waterrat http://url/ seq

won't do what you want. The 's', the 'e' and the 'q' get read by the
shell and passed as a string to the 'waterrat' command as another
command-line argument.

> also should the command look like this,
>
> firefox http://myurl.com/ | Ctrl-S | ENTER | Ctrl-Q
>
> or should it look like this,
>
> firefox http://myurl.com/ ; Ctrl-S ; ENTER ; Ctrl-Q
>
> or should it be a kind of control loop in bash,
>
> while [ 1 ]
> do
> firefox http://myurl.com/
> Ctl-S
> ENTER
> Ctl-Q
> done

None of the above.

> It is a simple idea, but I cannot get it to work.

You need a tool that can simulate the sending of keystrokes to a running
program. There are lots of these, and they all rely on extensive
knowledge of things way beyond the shell. On my X Windows system I use
xdotool. There is also xte.

Using these tools is tricky and fraile -- there can be timing problems,
problems choosing the right window to send to and so on. It's generally
an unreliable method.

What's wrong with wget or curl? It's almost certainly going to be
simper to make those do what you want than to get your script to work
correctly.

--
Ben.

dale

unread,
Feb 8, 2012, 10:55:31 PM2/8/12
to
On Feb 8, 9:44 am, dale5...@earthlink.net wrote:

> It is a simple idea, but I cannot get it to work.
> thank you.

Please disreguard the above post,
I've decided to try wget,
and/or curl instead of the above
bash script.

dale.

Kenny McCormack

unread,
Feb 8, 2012, 11:09:39 PM2/8/12
to
In article <6fa45586-159f-4bb2...@w19g2000vbe.googlegroups.com>,
There will always be sites that refuse to do anything useful when accessed
by a non-GUI browser (i.e., something like lynx or wget or curl). So, I
assumed that the site you were accessing was in that category - and that,
thus, your initial post was a reasonable one.

As others have noted, what you need is a GUI automator, for whatever
platform you are running on. Simply putting the keys into a text file is
unlikely to work.

What this boils down is that if you can get it to work with lynx/wget/curl,
then that's great, but I wouldn't be surprised to hear that you can't and
that you do, in fact, need to "automate the GUI".

--
"The anti-regulation business ethos is based on the charmingly naive notion
that people will not do unspeakable things for money." - Dana Carpender

Quoted by Paul Ciszek (pciszek at panix dot com). But what I want to know
is why is this diet/low-carb food author doing making pithy political/economic
statements?

Nevertheless, the above quote is dead-on, because, the thing is - business
in one breath tells us they don't need to be regulated (which is to say:
that they can morally self-regulate), then in the next breath tells us that
corporations are amoral entities which have no obligations to anyone except
their officers and shareholders, then in the next breath they tell us they
don't need to be regulated (that they can morally self-regulate) ...

Sivaram Neelakantan

unread,
Feb 9, 2012, 10:43:33 AM2/9/12
to
On Thu, Feb 09 2012,Kenny McCormack wrote:


[snipped 12 lines]

> There will always be sites that refuse to do anything useful when accessed
> by a non-GUI browser (i.e., something like lynx or wget or curl). So, I
> assumed that the site you were accessing was in that category - and that,
> thus, your initial post was a reasonable one.
>
> As others have noted, what you need is a GUI automator, for whatever
> platform you are running on. Simply putting the keys into a text file is
> unlikely to work.

Do you have any suggestions for those? People tell me about
autohotkey(Windows) and iMacro(addon) for Firefox but it all seems....so
clumsy.


[snipped 5 lines]


sivaram
--

--- Posted via news://freenews.netfront.net/ - Complaints to ne...@netfront.net ---

Kenny McCormack

unread,
Feb 9, 2012, 11:34:35 AM2/9/12
to
In article <82d39o2...@gmail.com>,
Sivaram Neelakantan <nsivar...@gmail.com> wrote:
...
>> As others have noted, what you need is a GUI automator, for whatever
>> platform you are running on. Simply putting the keys into a text file is
>> unlikely to work.
>
>Do you have any suggestions for those? People tell me about
>autohotkey(Windows) and iMacro(addon) for Firefox but it all seems....so
>clumsy.

They *are* "clumsy" in the sense of that they are faking keystrokes (and/or
mouse actions) as if the user were typing them - and this is obviously less
reliable than having a built-in way to do it. But, alas, as we move more
and more towards a pointy/clicky world where the emphasis is on fancy UIs,
it becomes less and less possible to avoid learning and practicing
"GUI automation".

Some random comments:

1) On Windows, I highly recommend WinBatch - which I have used extensively
for decades. As far as I can tell, WinBatch does it all, while most of the
other automation tools that I have seen aim only at a small slice of the
overall problem.

2) I've heard about iMacro for Firefox, and it sounds cool, but I've never
really had a need for it, since I have WinBatch.

3) Firefox does have a host of plug-ins/add-ons/what-evers that seem to do
just about everything. It seems like it might be possible to find one of
those that would address your problem.

--
Is God willing to prevent evil, but not able? Then he is not omnipotent.
Is he able, but not willing? Then he is malevolent.
Is he both able and willing? Then whence cometh evil?
Is he neither able nor willing? Then why call him God?
~ Epicurus

stan

unread,
Feb 9, 2012, 3:38:45 PM2/9/12
to
Sivaram Neelakantan wrote:
> On Thu, Feb 09 2012,Kenny McCormack wrote:
>
> [snipped 12 lines]
>
>> There will always be sites that refuse to do anything useful when accessed
>> by a non-GUI browser (i.e., something like lynx or wget or curl). So, I
>> assumed that the site you were accessing was in that category - and that,
>> thus, your initial post was a reasonable one.

I agree the most desired option is wget or curl and if those fail then
you are forced to simulate a gui.

I thought someone should point out that the things sites do to be
difficult wget and curl are done by choice and almost certainly with
intent. Don't be surprised if you find yourself chasing a moving
target.

>> As others have noted, what you need is a GUI automator, for whatever
>> platform you are running on. Simply putting the keys into a text file is
>> unlikely to work.
>
> Do you have any suggestions for those? People tell me about
> autohotkey(Windows) and iMacro(addon) for Firefox but it all seems....so
> clumsy.

I'm not aware on anything of note, but you might seek out the current
most popular handicapped access programs. I dont know about scripting
but many of them certainly have to struggle with handling a
confounding gui interface.

Kenny McCormack

unread,
Feb 9, 2012, 4:41:08 PM2/9/12
to
In article <lfnd09-...@invalid.net>, stan <smo...@exis.net> wrote:
>Sivaram Neelakantan wrote:
>> On Thu, Feb 09 2012,Kenny McCormack wrote:
>>
>> [snipped 12 lines]
>>
>>> There will always be sites that refuse to do anything useful when accessed
>>> by a non-GUI browser (i.e., something like lynx or wget or curl). So, I
>>> assumed that the site you were accessing was in that category - and that,
>>> thus, your initial post was a reasonable one.
>
>I agree the most desired option is wget or curl and if those fail then
>you are forced to simulate a gui.
>
>I thought someone should point out that the things sites do to be
>difficult wget and curl are done by choice and almost certainly with
>intent. Don't be surprised if you find yourself chasing a moving
>target.

Agreed. Well said.

>>> As others have noted, what you need is a GUI automator, for whatever
>>> platform you are running on. Simply putting the keys into a text file is
>>> unlikely to work.
>>
>> Do you have any suggestions for those? People tell me about
>> autohotkey(Windows) and iMacro(addon) for Firefox but it all seems....so
>> clumsy.
>
>I'm not aware on anything of note, but you might seek out the current
>most popular handicapped access programs. I dont know about scripting
>but many of them certainly have to struggle with handling a
>confounding gui interface.
>

I meant to add in my previous post that there are a few "GUI automators" for
X - e.g., xte and xdotool. I've never used either (mostly because I don't
do enough surfing type activity on Linux to have ever really needed it), but
a little Googling shows that both of these tools are based on the "XTest"
extension.

--
Just for a change of pace, this sig is *not* an obscure reference to
comp.lang.c...

0 new messages