|
Read file /text data into a web app.
Greetings from a java programmer,
I have used this piece of code which has worked REALLY WELL sending data from a java applet;-
#!/usr/bin/perl -w
$address = "My specified route on the server + $filename";
open(OUT, ">$address");
print "content-type: text/plain\n\n";
while (<>) {
print OUT $_;
print $_;
}
close (OUT);
exit 0;
# end of script
What I would LOVE is to have a generic script to read in data from a file specified in the $address eg --->
$address = "/myData/users/jonsFile.txt";
I did a search before submitting this and found this;-
#!/usr/bin/perl -w
# use strict; // blocked, but what does this do ?
$fileref = "myFile.txt";
$file = "My specified route on the server + $filename";
chomp(my $line = <STDIN> ); // don't get this bit?
open (DUMP, ">>$file") || die "Couldn't open $fileref, sorry";
print DUMP "[",scalar localtime,"] $line\n";
close DUMP;
print "Information sent from $fileref\n";
# end of script
I made one or two changes here and there, so I hope I haven't cocked it up.
So, folks - please! Can I have a generic 'readThisFile' script?
Thank you very much in advance to all who read this post.
PS: security isn't an issue I think as only the specfied files will be accessible according to each script.
|