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.