By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,807 Members | 1,995 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,807 IT Pros & Developers. It's quick & easy.

am trying to run a programme which is using PGPLOT.When I call it from browser I get

P: 5
I am trying to run a programme which is using PGPLOT.When I call it from browser I get following error message.
--------
%PGPLOT, Unable to read font file: grfont.dat %PGPLOT, Use environment variable PGPLOT_FONT to specify the location of the PGPLOT grfont.dat file. %PGPLOT, PGENV: no graphics device has been selected %PGPLOT, PGBBUF: no graphics device has been selected %PGPLOT, PGMTXT: no graphics device has been selected %PGPLOT, PGMTXT: no graphics device has been selected %PGPLOT, PGMTXT: no graphics device has been selected %PGPLOT, PGEBUF: no graphics device has been selected
----------
grfont.dat file is on on my system under c:\XAMPP\perl\lib and I have set it as enviorment variable PGPLOT_FONT.
Any help will be much appreciated.
Thanks,
Apr 16 '10 #1
Share this Question
Share on Google+
7 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
Maybe you can shed some light on this, but how is this a Perl problem? If you are coding something to run it using Perl, then you need to please post your code here. If not, I will have to move this question to a more suitable category.

Regards,

Jeff
Apr 18 '10 #2

P: 5
hanks for your response.Sorry if I didn't explain it properly.Yes I am using a perl script.
In fact it works fine from the command line but only when I call it from browser.I get this error.
Even I tried to add the enviorment variable to code itself
$ENV{PGPLOT_FONT} ||= 'c:\XAMPP\perl\lib\grfont.dat';
But it still cannot pick it.
if you need more info.Please let me know.
Thanks,
Bilal
Apr 18 '10 #3

numberwhun
Expert Mod 2.5K+
P: 3,503
We are going to have to see your script if we are going to help you. Even then there are no guarantees, but at least we will have a better idea of what you are trying to do.

Regards,

Jeff
Apr 18 '10 #4

P: 5
@numberwhun
Expand|Select|Wrap|Line Numbers
  1. #!"C:\xampp\perl\bin\perl.exe" -w
  2.  
  3. # TRG:    Perl Script to plot graph using PGPLOT
  4. #     the output is sent to a UUID named file in WWW/tmp directory
  5.  
  6.  
  7. use strict;
  8. use Time::Local;
  9. use Time::Piece;
  10. use Time::Piece::MySQL;
  11. use DBI;
  12. use Data::Dumper;
  13. use Switch;
  14. use POSIX;
  15. use CGI qw(:standard);
  16. use CGI::Carp qw(fatalsToBrowser);
  17. use PGPLOT;
  18. use Algorithm::CurveFit;
  19. use strict; use warnings;
  20.  
  21. print "Content-type: text/html\n\n";
  22. print Dumper(\%ENV);
  23. $ENV{PGPLOT_FONT} ||= 'c:\XAMPP\perl\lib\grfont.dat';
  24. my $database = 'prism';
  25. my $username = 'prism_user';
  26. my $password = 'pr1sm_pass';
  27.  
  28. # Default patient to simplify rapid testing
  29. my $patient_forename = 'random';
  30. my $patient_surname  = 'test';
  31.  
  32.  
  33. # Retrieve graph types and time limits from GET ?
  34. my $start_time = param("from");
  35. my $end_time   = param("to");
  36. my $graph_type = param("type"); # day week or time
  37. my $patient_id = param("pid");
  38. # Diagnostic output
  39. print "Graph for pid=${patient_id}, type=${graph_type}, from=${start_time}, to=${end_time} <br>\n";
  40. # connect to databse
  41. my $dbh = DBI->connect(('DBI:mysql:' . $database), $username, $password)
  42.           || die "Database Connection Failure: $!";
  43.           # find patient
  44. my $patient;
  45. if ($patient_id)
  46.   { $patient = get_patient_byid($dbh,$patient_id);}
  47. else
  48.   { $patient = get_patient_byname($dbh,$patient_forename,$patient_surname); }
  49.  
  50. # get reading dates[0] and value[1] as a structure
  51. my @readings = get_readings($dbh,$patient, $start_time,$end_time);
  52. my @limits = get_current_limits($dbh,$patient);
  53.  
  54. # done with the database
  55. $dbh->disconnect();
  56. # GPAPH USING PGPLOT
  57.  
  58. my $xmin = 0;
  59. my $xmax = 1;
  60. my $ymin = 0;
  61. my $ymax = 32;  # TRG 26Aug08 changed to 32
  62. my $xlabel = 'X';
  63.  
  64. # Set X-axis range and labelling appropriate to graph_type
  65. switch ($graph_type) {
  66.   case "day"  { $xmin=6; $xmax=24+6; $xlabel='hours in day';}
  67.   case "week" { $xmin=1; $xmax=8;  $xlabel='days of week';}
  68.   case "time" { $xmin=$start_time; $xmax=$end_time; $xlabel='date-time'; }
  69.   else   { print "ERROR: Unrecognised graph type\n" }
  70. }
  71. # Initialise PGPLOT
  72.  
  73. #pgbegin(0,"${output_path}${output_file}/PNG",1,1); # 1,1 is number of x,y subplots
  74.  
  75. pgenv($xmin,$xmax,$ymin,$ymax,0,0); # final number -1 for no axes..
  76.  
  77. pglabel($xlabel,'Glucose, mmol/L',$graph_type);
  78.  
  79.  
  80. # ----------------------------------------------------------------------
  81.  
  82.  
  83. # Search for patient-ref given forename and surname
  84. sub get_patient_byname { # (handle,forename,surname) returns patient-ref
  85.     my $dbh = shift;
  86.     my $forename = shift;
  87.     my $surname = shift;
  88.  
  89.     my $query = $dbh->prepare(
  90.         "SELECT * FROM patients WHERE p_forename = ? AND p_surname = ?");
  91.  
  92.     print "Looking for patient by name ($forename $surname)\n";
  93.     $query->execute($forename,$surname);
  94.     my $patient = $query->fetchrow_hashref()
  95.         || die "coulnt find patient\n";
  96.     $query->finish();
  97.     return $patient;
  98. }
  99.  
  100.  
  101. # Search for patient-ref given pid
  102. sub get_patient_byid { # (handle,pid) returns patient-ref
  103.     my $dbh = shift;
  104.     my $pid = shift;
  105.  
  106.     my $query = $dbh->prepare(
  107.         "SELECT * FROM patients WHERE pid = ?");
  108.  
  109.     #print "Looking for patient by ID($pid)\n";
  110.     $query->execute($pid);
  111.     my $patient = $query->fetchrow_hashref()
  112.         || die "coulnt find patient\n";
  113.     $query->finish();
  114.     return $patient;
  115. }
  116.  
  117.  
  118.  
  119.  
  120. # get patients readings within date range as (dtg,value)
  121. sub get_readings { # (handle,patient-ref,start_time,end_time) returns readings
  122.     my $dbh = shift;
  123.     my $patient = shift;
  124.     my $start_time = gmtime(shift);
  125.     my $end_time = gmtime(shift);
  126.     my $pid = $patient->{'pid'};
  127.     my (@results) = ();
  128.  
  129.     my $query = $dbh->prepare(
  130. #        "SELECT meter_dtg, value FROM readings ".
  131. #    "WHERE pid = ? AND meter_dtg>=? AND meter_dtg <=?");
  132.  
  133.         "SELECT meter_dtg,value,lo_val,hi_val,lo_avg,hi_avg FROM readings,limits ".
  134.     "WHERE readings.lid = limits.lid AND readings.pid = ? AND meter_dtg>=? AND meter_dtg <=? ".
  135.     "ORDER BY meter_dtg");
  136.     # note that there are two PID fields
  137.  
  138.     $query->execute($pid,$start_time->mysql_datetime,$end_time->mysql_datetime);
  139.     while (my @ary = $query->fetchrow_array())
  140.     {
  141.        push(@results, [@ary]); # store the reference
  142.     }
  143.     $query->finish();
  144.  
  145.     #print Dumper(@results);
  146.     return @results;
  147. }
  148.  
  149.  
  150. sub get_current_limits { # (handle,patient-ref) returns current limits for patient
  151.     my $dbh = shift;
  152.     my $patient = shift;
  153.     my $pid = $patient->{'pid'};
  154.     my (@results) = ();
  155.  
  156.     my $query = $dbh->prepare(
  157.         "SELECT lo_val,hi_val,lo_avg,hi_avg FROM limits,patients ".
  158.     "WHERE limits.lid=patients.current_lid AND patients.pid=?");
  159.  
  160.     $query->execute($pid);
  161.     while (my @ary = $query->fetchrow_array())
  162.     {
  163.        push(@results, [@ary]); # store the reference
  164.     }
  165.     $query->finish();
  166.  
  167.     #print "<<<<<". Dumper(@results) .">>>>>>><br>\n";
  168.     return @results;
  169. }
  170.  
Apr 18 '10 #5

numberwhun
Expert Mod 2.5K+
P: 3,503
@bamusic You will probably notice that I have deleted the thread you created today. Creating a new thread with the same content is called creating a duplicate thread. If you are not getting a reply, then keep the thread active and ask if anyone has a suggestion.

I took a look briefly, but am not sure why you are having the issues you are. Hopefully someone will respond to you, but please refrain from creating duplicate threads as it makes more work for those of us maintaining the site, who have to clean it up.

Regards,

Jeff
Apr 20 '10 #6

P: 5
@numberwhun
Sorry about that.I actually was posting few forums and probably lost the site.
Apr 21 '10 #7

P: 1
You probably have this fixed by now, and I'm by no means an expert, but I've noticed you've commented out your pgbegin line. There is no device set for pgplot to know where to plot to.

Line 73 #pgbegin(0,"${output_path}${output_file}/PNG",1,1); # 1,1 is number of x,y subplots
Jun 11 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.