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

Randy Kramer rhkramer at gmail.com
Mon Nov 27 15:06:42 GMT 2006


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
>
> ;-)




More information about the kfm-devel mailing list