Skip Menu |

This queue is for tickets about the GraphViz CPAN distribution.

Report information
The Basics
Id: 14189
Status: resolved
Priority: 0/
Queue: GraphViz

People
Owner: Nobody in particular
Requestors: jerome [...] eteve.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.02
Fixed in: (no value)



Subject: graph viz does not work within apache
My conf: GraphViz 2.02 uname -a Linux -- 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686 i386 GNU/Linux Apache/2.0.40 perl v5.8.0 built for i386-linux-thread-multi When am using GraphViz from command line, it works perfectly, but within apache, it fails to fill the output file when it works as a cgi. Here is my CGI: #! /usr/bin/perl -w use GraphViz; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); my $g = GraphViz->new( directed => 0 ); my $europe = { name =>'Europe', style =>'filled', fillcolor =>'lightgray', fontname =>'arial', fontsize =>'12' }; $g->add_node('London' , shape => 'hexagon' , URL => 'http://www.eteve.net/', cluster=> $europe ); $g->add_node('Paris', cluster => $europe ); $g->add_node('New York'); $g->add_node('LA', label => '' , style => 'invis' , height => 0 , width => 0 , shape => 'circle' , ); $g->add_node('Amsterdam', cluster => $europe); $g->add_edge('London' => 'Paris'); $g->add_edge('London' => 'New York', label => 'Far'); $g->add_edge('Paris' => 'LA' , label => 'Very far'); $g->add_edge('LA', 'New York', label => 'Not so far'); $g->add_edge('Paris' => 'London' ,minlen => 0 , weight => 100 ); open IMG , ">/tmp/img.jpg"; binmode IMG ; print IMG $g->as_jpeg; close IMG ; The problem is the image /tmp/img/jpeg is zero sized. When the GraphViz code is ran from the command line, it works perfectly.
[JETEVE - Tue Aug 16 11:20:52 2005]: Show quoted text
> My conf: > > GraphViz 2.02 > > uname -a > Linux -- 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686 i386 > GNU/Linux > > Apache/2.0.40 > perl v5.8.0 built for i386-linux-thread-multi > > When am using GraphViz from command line, it works perfectly, but > within apache, it fails to fill the output file when it works as a > cgi. > > > Here is my CGI: > > #! /usr/bin/perl -w > use GraphViz; > > use CGI qw(:standard); > use CGI::Carp qw(fatalsToBrowser); > > > my $g = GraphViz->new( directed => 0 ); > > my $europe = { > name =>'Europe', > style =>'filled', > fillcolor =>'lightgray', > fontname =>'arial', > fontsize =>'12' > }; > > > $g->add_node('London' , shape => 'hexagon' , URL => > 'http://www.eteve.net/', cluster=> $europe ); > $g->add_node('Paris', cluster => $europe ); > $g->add_node('New York'); > $g->add_node('LA', label => '' , style => 'invis' , > height => 0 , > width => 0 , > shape => 'circle' , > ); > > $g->add_node('Amsterdam', cluster => $europe); > > $g->add_edge('London' => 'Paris'); > $g->add_edge('London' => 'New York', label => 'Far'); > $g->add_edge('Paris' => 'LA' , label => 'Very far'); > $g->add_edge('LA', 'New York', label => 'Not so far'); > > $g->add_edge('Paris' => 'London' ,minlen => 0 , weight => 100 ); > > open IMG , ">/tmp/img.jpg"; > binmode IMG ; > print IMG $g->as_jpeg; > close IMG ; > > > The problem is the image /tmp/img/jpeg is zero sized. > > When the GraphViz code is ran from the command line, it works > perfectly.
I found someone having the same problem on windows: See http://www.thescripts.com/forum/thread50725.html
Just set a HOME environment variable within apache and it will work. For instance, I setted HOME to /tmp/ and it fixed the problem. Carefull when you use user webspace apache module. By default, it prevent you to set your own environment variable. You got to desactivate the suexe apache feature to do this.
This issue is fixed in GraphViz2 V 1.00. At least, I (Ron) assume it's fixed - I did not test it. What happens is that GraphViz2 uses File::Temp to create a temporary file, writes the dot commands into that file, runs dot (or whatever you chose), and captures the output with Capture::Tiny. Then, if you've requested the output to be written to a file, it opens that file and writes to it. Of course, you must have permission to write that file. Alternately, you can get the output of dot with the dot_output() method, and send it to the client, or write it to some other file. There're won't be any further development on GraphViz.