Complete.Org: Mailing Lists: Archives: discussion: July 2001:
[aclug-L] webcam.cgi
Home

[aclug-L] webcam.cgi

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: discussion@xxxxxxxxx
Subject: [aclug-L] webcam.cgi
From: Jonathan Hall <jonhall@xxxxxxxxxxxx>
Date: Tue, 3 Jul 2001 00:58:07 -0500
Reply-to: discussion@xxxxxxxxx

Here is the webcam.cgi script I was refering to at the meeting.  If you have
any questions about it, feel free to let me know.

I have included the script as plain text in the body of this message since I
believe the mailing list filters out attachments.  You will need to save the
entire message to a file called webcam.cgi, then edit out the parts up to
and including the "BEGIN HERE" line and the parts after and including the
"END HERE" line.

Good luck.


--- BEGIN HERE ---
#!/usr/bin/perl -w

######
###### This script was originally written by Jonathan Hall.  I hereby
###### release it into the public domain, simply b/c I'm too lazy to
###### worry about assigning an open-source license to it.
######
###### This script comes with absolutely no warranty whatsoever.  USE IT
###### SOLEY AT YOUR OWN RISK!!!
######
###### Feel free to submit bug reports, fixes, or improvements to
###### jonhall@xxxxxxxxxxxx
######
###### It should be noted that this script currently requires the use of
###### 'jpeginfo' which I installed by way of the Debian package of the same
###### name.  On non-Debian systems you may be required to compile and
###### install this program otherwise.
######
###### It should be noted that this file MUST be edited to work.  There are
###### a few configuration options below that need to be modified for this
###### script to function properly.
######
###### Have fun.
######

use Time::localtime;
use File::Copy;
use CGI;
$query = new CGI;
###
### General Configuration Options
###
$title = "My WebCam";                   # Pages' title
$interval = 30;                         # Seconds between updates

###
### Nitty-gritty Configuration Options
###

# The URL where a person can access this CGI file
$cgi_url = "http://some.host.com/~user/cgi-bin/webcam.cgi";;

# Full path and filename where this script can find the new image
$new_image = "/home/user/cam/webcam.jpg";

# Full path and filename where this script can store the old (or current)
# image until it is no longer needed.
$old_image = "$new_image.old";


# Don't mess with stuff below here unless you know what you're doing (I
# guess that means I shouldn't be messing with this stuff, huh?)
$date = time();
$image_url = "$cgi_url?jpeg=1";

$chk_image = "/usr/bin/jpeginfo -c $new_image 2>&1 | egrep '[OK]' > /dev/null";
#@chk_image = ("/usr/bin/jpeginfo", "-c", $new_image);

if ($query->param("jpeg")) {
  print "Content-type: image/jpeg\n\n";

   unless(system $chk_image) {          # Check if new image is complete
    move($new_image, $old_image)
      or die "File move failed: $!";    # New image is complete, so copy it
    if ($archive_dir) {
      copy($old_image, "$archive_dir/$archive_file");
    }
  }
  open(IMAGE, $old_image);
  while(<IMAGE>) {
    print $_;
  }

} else {
print <<"EOF";
Content-type: text/html

<HTML>
 <HEAD>
  <TITLE>$title</TITLE>
 </HEAD>
 <META HTTP-EQUIV="Refresh" CONTENT="$interval; url=$cgi_url?$date">
 <META HTTP-EQUIV="Progma" CONTENT="no-cache">
 <BODY>
  <p align="center"><a href="$image_url">
   <img nosave width="320" height="240" src="$image_url?$date"></a>
  <p align="center"><font size="4">$title</font>
  <br>(Updates every $interval seconds)
  <br>
  <font size=-2>$date</font>
 </BODY>
</HTML>
EOF
}
--- END HERE ---
-- This is the discussion@xxxxxxxxx list.  To unsubscribe,
visit http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi


[Prev in Thread] Current Thread [Next in Thread]
  • [aclug-L] webcam.cgi, Jonathan Hall <=