# Rails, htmldoc and cgi

**URL:** <https://www.ruby-forum.com/t/rails-htmldoc-and-cgi/122406>\
**Category:** Ruby\
**Created:** [December 7, 2007, 11:01am UTC](https://www.ruby-forum.com/t/rails-htmldoc-and-cgi/122406 "2007-12-07T11:01:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bober](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b5e925/32.png) [@Bober](https://www.ruby-forum.com/u/Bober)\
**Post date:** [December 7, 2007, 11:01am UTC](https://www.ruby-forum.com/t/rails-htmldoc-and-cgi/122406/1 "2007-12-07T11:01:09Z")

</div>

Hello,  
I have some problems with external proces, which is started by rails.

I have found something about generate pdf in rails:

[http://wiki.rubyonrails.org/rails/pages/HowtoGeneratePDFs](http://wiki.rubyonrails.org/rails/pages/HowtoGeneratePDFs)

I would like use htmldoc

but I have a problem with broken pipe.

```auto
add_variables_to_assigns
    htmldoc_env = "HTMLDOC_NOCGI=TRUE;export HTMLDOC_NOCGI"
    generator = IO.popen("#{htmldoc_env};htmldoc -t pdf --path
\".;http://#{@request.env["HTTP_HOST"]}\" --webpage -", "w+")
    generator.puts @template.render("article/pdf")
    generator.close_write

    send_data(generator.read, :filename => "test.pdf", :type =>
"application/pdf")
```

When I run it directly from shell everything is ok,  
but when I ruby it from method in rails controller,  
I see “Broken pipe”.

I think, that there is a problem, because rails are cgi process and  
htmldoc not. How to improve this?  
Can I run htmldoc as cgi process?

---

<div class="post-metadata">

**Author:** ![Bober](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b5e925/32.png) [@Bober](https://www.ruby-forum.com/u/Bober)\
**Post date:** [December 8, 2007, 2:07am UTC](https://www.ruby-forum.com/t/rails-htmldoc-and-cgi/122406/2 "2007-12-08T02:07:11Z")

</div>

> I have some problems with external proces, which is started by rails.

Hi - this isn’t the Rails list - but fwiw you want to avoid starting  
external processes in Rails. It has pitfalls. Ask on the Rails list  
about BackgrounDRb.

–  
Giles B.

Podcast: [http://hollywoodgrit.blogspot.com](http://hollywoodgrit.blogspot.com)  
Blog: [http://gilesbowkett.blogspot.com](http://gilesbowkett.blogspot.com)  
Portfolio: [http://www.gilesgoatboy.org](http://www.gilesgoatboy.org)  
Tumblelog: [http://giles.tumblr.com](http://giles.tumblr.com)
