Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux Hosts
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > GNU Linux Zone > Linux Newbie
Reload this Page couple questions on were some CGI scripts go
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Linux Newbie If you're new to the wonderful world of Linux, start here!

Reply
 
Thread Tools Display Modes
Old 12-01-2007   #1 (permalink)
wrigh113
Just Joined!
 
Join Date: Nov 2007
Posts: 4
couple questions on were some CGI scripts go

Hi Folks,

I'm putting this here since you will be dealing with a newbie although I'm sure this could go into another forum.

I'm attempting to get a script to create a png image of some temperature data that I'm collecting in a RRDT database. As far as I can tell the database is being updated via a cron job.

Now the author of the software does give a script that can be used to produce the graphs for display.

Does this file go into the www/cgi-bin folder on my linux box?

How is it run? How do I know what the file name of the png image is?

My thinking and of course lack of programming skills would say this script would run, create a file called XYZ.png, put it in folder ABC and from there I could have a web page pull the file from that folder and display it on the web.

Paths listed for the perl and rrdt are correctly listed for my system btw in this example

PHP Code:
#!/usr/bin/perl -w
#
# DigiTemp v2.1 RRDB Temperature Graph
#
# Copyright 1997-2001 by Brian C. Lane <bcl@brianlane.com> www.brianlane.com
# All Rights Reserved
#

# REQUIRES:
#  RRD tool binary
#  CGI (comes with perl5)

use RRDp;
use 
CGI;

$cgi = new CGI;                   # Load the CGI routines

# Find the RRD executable, look in the standard locations
# If your rrdtool is installed someplace else, fill in the proper location
# below:
if ( -"/usr/bin/rrdtool"
{
  
RRDp::start "/usr/bin/rrdtool";
elsif ( -"/usr/local/bin/rrdtool") {
   
RRDp::start "/usr/local/bin/rrdtool";
elsif ( -"/usr/local/rrdtool/bin/rrdtool" ) {
   
RRDp::start "/usr/local/rrdtool/bin/rrdtool";
} else {
   die 
"Could not find rrdtool binary\n";
}

# The RRD database to get the data from
$rrd "/tmp/digitemp.rrd";


# Make the variables easier to use and assign defaults if not set
if( !$cgi->param('starttime') )
{
    
$starttime "-1day";
} else {
    
$starttime $cgi->param('starttime');
}
if( !
$cgi->param('endtime') )
{
    
$endtime time;
} else {
    
$endtime $cgi->param('endtime');
}
if( !
$cgi->param('width') )
{
    
$width "400";
} else {
    
$width $cgi->param('width');
}
if( !
$cgi->param('height') )
{
    
$height "100";
} else {
    
$height $cgi->param('height');
}
if( !
$cgi->param('label') )
{
    
$label="";
} else {
    
$label $cgi->param('label');
}
$var $cgi->param('var');

# Diagnostic output
#print STDERR "start  = $starttime\n";
#print STDERR "end    = $endtime\n";
#print STDERR "width  = $width\n";
#print STDERR "height = $height\n";
#print STDERR "var    = $var\n";
#print STDERR "label  = $label\n";


# Output a HTML header for the PNG image to follow
print $cgi->header('image/png');

# Generate the graph
RRDp::cmd "graph - --imgformat PNG",
    
"--start '$starttime' --end '$endtime'",
    
"--width $width --height $height",
    
"DEF:room_c=$rrd:room:AVERAGE",
    
"DEF:attic_c=$rrd:attic:AVERAGE",
    
"DEF:desk_c=$rrd:desk:AVERAGE",
    
"CDEF:room_f=room_c,9,*,5,/,32,+",
    
"CDEF:attic_f=attic_c,9,*,5,/,32,+",
    
"CDEF:desk_f=drink_c,9,*,5,/,32,+",
    
"LINE1:room_f#00FF00:'Computer Room'",
    
"LINE1:attic_f#FF0000:'Attic'",
    
"LINE1:desk_f#0000FF:'Desk'";

$answer=RRDp::read;

print $
$answer;

RRDp::end
wrigh113 is offline   Reply With Quote
Old 12-01-2007   #2 (permalink)
ianj001
Just Joined!
 
ianj001's Avatar
 
Join Date: Oct 2006
Location: Harrisburg, PA
Posts: 29
The image will show up in the web page. You can save it from there. You need to put this script in 'webroot' cgi-bin directory. That may be www/cgi-bin in your case. Then call the script from a web browser using http://yourserver/cgi-bin/scriptname where yourserver is your website and scriptname is the name of the script you listed here.
ianj001 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
openSUSE 10.2 on a Laptop - A Couple Configuration Questions rdhart07 SuSE Linux Help 0 04-03-2007 05:33 AM
Couple of questions regarding Mplayer Dpontes11 Linux Applications 3 04-15-2006 12:36 AM
Couple questions.. fantastic_damage SuSE Linux Help 3 04-11-2006 08:50 PM
a couple of scripting questions for a small project that i've decided to try josolanes Linux Programming & Scripting 15 11-02-2005 11:15 AM
Asking good questions (2) jasonlambert Linux Newbie 5 12-13-2004 09:22 PM




All times are GMT. The time now is 12:33 AM.




© 2000 - 2008 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.0.0