Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #
- # Takes post from webpage and sends it to a temp file for Arduino to eventually see.
- #
- local ($buffer, @pairs, $pair, $name, $value, %FORM);
- # Read in text
- $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
- if ($ENV{'REQUEST_METHOD'} eq "POST")
- {
- read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
- }else {
- $buffer = $ENV{'QUERY_STRING'};
- }
- # Split information into name/value pairs
- @pairs = split(/&/, $buffer);
- foreach $pair (@pairs)
- {
- ($name, $value) = split(/=/, $pair);
- $value =~ tr/+/ /;
- $value =~ s/%(..)/pack("C", hex($1))/eg;
- $FORM{$name} = $value;
- }
- if($temper = $FORM{temper})
- {
- `echo "$temper:Temp\n" > /tmp/Thermo`;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement