Sending HTML to konqueror from the command line (via a named pipe)

Rene Horn the.rhorn at gmail.com
Mon Nov 27 16:57:22 GMT 2006


I have v1.10, so yours should work the same way.  A less elegant
manner of doing this is just to pipe it in with cat.

$ cat foo.html|nc -lp 8081 -q 10
$ echo "<HTML><HEAD></HEAD><BODY>TEST</BODY></HTML>" > foo.html #This
is in a different terminal, of course.
$ konqueror http://localhost:8081

Unfortunately, netcat won't know when to close the connection, and so
the browser--in this case Konqueror--will just keep on waiting for
more input, even though there is none.

Rene

PS The "-e" option requires its own script file.  So try putting the
commands you want into something like htmlstream.sh, and then do the
following:

$ nc -lp 8081 -e htmlstream.sh

On 11/27/06, Randy Kramer <rhkramer at gmail.com> wrote:
> On Sunday 26 November 2006 08:13 pm, Randy Kramer wrote:
> > On Sunday 26 November 2006 03:19 pm, Rene Horn wrote:
> > > nc + konqi definitely works for streaming html. It's not elegant, but
> > > it works. I basically used the following commands to do it:
> > >
> > > $ mkfifo foo.html
> > > $ nc -lp 8081 -c "/bin/cat foo.html" # Of course, the port doesn't
> > > need to be 8081--that was just the first number I came up with.
> > > $ konqueror http://localhost:8081 & # This command was done in a
> > > different terminal, of course.
> > > $ echo "<HTML><HEAD></HEAD><BODY>TEST</BODY></HTML>" > foo.html
> >
> > Wonderful--thank you!
>
> Oops, just got nc and installed it, and no dice.
>
> My version is 1.10 and it has no -c option.  So I guessed that maybe the -e
> option is the same or similar, but no dice.
>
> What version of netcat are you using?
>
> My symptoms include that:
>
>    * On my first try (which I don't remember so well), the nc command hung
> until I started konqueror, then konqueror displayed some sort of error
> message--I can't recall what it was (maybe something like an address not
> found, but my memory is really bad at times).
>
>    * On subsequent tries, when I issue nc -lp 8081 -e "/bin/cat /rhk/foo.html"
> before starting konqueror (on a 2nd try), I get an error message: Can't grab
> 0.0.0.0:8081 with bind.  (/bin/cat is the right path to cat, /rhk/foo.html is
> the right name for the fifo).  In fact, I get this message whether konqueror
> is started or not.  When konqueror is started, it hangs with "localhost
> contacted, waiting for reply", and eventually: "An error occurred while
> loading http://localhost:8081:; Timeout on server;  localhost"
>
> I'm looking for documentation on the -c option.  Ok, found some hints:
>
> "netcat v0.7.0 o Added command line switch `-c' (close), which shuts down the
> connection on EOF from stdin without waiting for any answer ..."
>
> Which makes it sound like -q with some (small) number of seconds might be an
> alternate, but no luck there either:
>
> [rhk at s14 ~]$ nc -lp 8081  -q 15 "/bin/cat /rhk/foo.html &"
> /bin/cat /rhk/foo.html &: forward host lookup failed: Unknown server error
>
> So I'll keep looking, and try to download netcat version 0.7.0, but I could
> probably use some more hints. ;-)
>
> Randy Kramer
>
> > Randy Kramer
> >
> > > And that's pretty much it. I even put the entire thing into a loop
> > > just for fun:
> > >
> > > $ i=1; while true; do nc -lp 8081 -c "/bin/cat foo.html &"; echo
> > > "<HTML><HEAD></HEAD><BODY>TEST</BODY></HTML>" > foo.html; echo $i;
> > > i=`expr $i + 1`; done
> >
> > ;-)
>


-- 
the.rhorn at gmail.com, rhorn at sdf.lonestar.org,
hornr18 at uwosh.edu (UW-Oshkosh email address),
http://rhorn.unixcab.org - a bunch of experimental stuff
SDF Public Access UNIX System - http://sdf.lonestar.org

Jay Leno in response to Colin Powell's deadline for an Iraqi
constitution:
"They can take ours.  After all, we aren't using it..."




More information about the kfm-devel mailing list