freelanceprogrammers.org Forum Index » Perl

Need Help W/ Script


View user's profile Post To page top
czernyman Posted: Thu Aug 12, 1999 7:22 am


Joined: 13 Jul 1999

Posts: 2
Need Help W/ Script
I am trying to make a script that will log the
use of an audio file, and then read and return it. I
can`t get this to work. I`ve done a lot of different
things to get it to work, but they are useless. It might
have somthing to do with the script print location
instead of the file, but I don`t really know how to print
the file. I can`t use the foreach loop I think
because it would print the lines in random order. And,
the files are on a totally different server, so I
don`t think I can read them. Anyway, this is the code I
have now:<br><br><br>#!/usr/bin/perl<br><br>#get query
string<br>@values = split(/&/,$ENV{`QUERY_STRING`});<br>foreach $i
(@values) {<br>($varname, $mydata) =
split(/=/,$i);<br>$FORM{$varname} = $mydata;<br>}<br><br>#get the
date<br>shortdate
= `date +"%D %T
%Z"`;<br>chop($shortdate);<br><br>#enter into
log<br>open(OUTF,"&gt;&gt;midi.db") or
&dienice("Couldn`t open file for writing. Please notify
mts-iscool@juno.com.");<br>print OUTF "Date: $shortdate|File:
$FORM{`file`}|Extension: $FORM{`type`}";<br>close(OUTF);<br><br>#grab
file<br>open(INF,"&lt;$FORM{`file`}") or &dienice("Couldn`t open $FORM{`file`}
for
reading. Please notify mts-iscool@juno.com.");<br>@data =
&lt;INF&gt;;<br>close(INF);<br><br>#print mime<br>print
"Location:$FORM{`file`}

";<br><br>sub dienice {<br>($msg) = @_;<br>print
"Content-type:text/html

";<br>print "&lt;h2&gt;Error&lt;/h2&gt;
";<br>print
$msg;<br>exit;<br>}
Reply with quote
Send private message
View user's profile Post To page top
Rob_Wilson_98 Posted: Fri Aug 13, 1999 1:39 am


Joined: 02 Aug 1999

Posts: 11
Need Help W/ Script
The location MIME is just to redirect to another
URL. If you give it a file, your browser won`t know
what to do with it.<br><br>What you should do is:
<br>print "Content-type: audio/???

";<br>binmode
STDOUT;<br>print @INF;<br>close STDOUT;<br><br>If this doesn`t
work, then you will need to instead do:<br><br>print
"Location: $FORM{`file`}

";<br>#assuming that is a
URL<br><br><br>Even if they are on a different server, if they can be
accessed through the web at all, you can use that URL to
access them in your Location:.<br><br>HTH
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help