View Single Post
  #29   Report Post  
Posted to rec.crafts.metalworking
James Waldby James Waldby is offline
external usenet poster
 
Posts: 271
Default Trepanning and Parting Off / Handling URL's

On Tue, 06 May 2008 05:08:39 +0000, DoN. Nichols wrote:
On 2008-05-05, James Waldby wrote:
On Mon, 05 May 2008 00:59:21 +0000, DoN. Nichols wrote:
On 2008-05-03, James Waldby wrote:

[ ... ]
O.K. But I normally don't have Opera up and running, so I
invoke it by a script "op" which does a cd to a place where I tend to
save things, then invokes opera via the URL which I cut-and-pasted
into the command line -- and the command line sees the newlines as end
of a command line and the start of another, which of course fails to
reach the place desired and then tries to interpret the other two as
separate commands, which also normally fail. :-) So I have to cut and
paste it one line at a time, and surround the whole thing with double
quotes to keep any stray '?', '%' or similar characters with special
meanings to the shell from having those meanings.

...
Add the following near the beginning of the script:
URL="`xclip -o | tr -d '\n'`"


[snip re fetch and compile xclip]

Hmm ... "Reads from standard in, or from one or more files,"


Later in the man page: "xclip can also print the contents of a selection
to standard out with the -o option." Also see last example in man page.

But the script is invoked as:

op URL-goes-here

and when URL occupies three lines, this would still be:

op FIRST-LINE-OF-URL (opera barfs because of incomplete URL)
SECOND-LINE-OF-URL (shell barfs, because it is expecting a new valid
command) THIRD-LINE-OF-URL (shell barfs, because it is expecting a new
valid commnd)

So -- unless you can see a way to drop the cut-and-paste as
standard input for the script, I don't see how this can work.

....

I meant that you'd change the script to invoke without command line
parameters. Get URL from current selection. The current selection
is whatever you most recently copied or cut or xclip -i'd.
For example, when I left drag the mouse cursor over the two lines:
test 1 @ 2 $ 3 % 4
test 5 ? 6 # 7 ! 8
and then execute URL="`xclip -o | tr -d '\n'`"; echo "/$URL/"
bash displays: / test 1 @ 2 $ 3 % 4 test 5 ? 6 # 7 ! 8/

To use URL from command line when given, else use selection:
U=$1
[ "$U" ] || U="`xclip -o | tr -d '\n'`"
firefox "$U"

-jiw