source: trunk/gsdl/cgi-bin/download@ 7768

Last change on this file since 7768 was 7766, checked in by davidb, 20 years ago

launch upload and download CGI scripts added to support remote collection
building through GLI applet.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.1 KB
Line 
1#!/usr/bin/perl -w
2
3use CGI;
4use usabcgi;
5
6sub init_cgi
7{
8 my $line = <STDIN>;
9 my $cgi;
10
11 if ((defined $line) && ($line ne "")) {
12 $cgi = new CGI($line);
13 }
14 else {
15 $cgi = new CGI();
16 }
17
18 return $cgi;
19}
20
21sub clean_param
22{
23 my ($cgi,$param) = @_;
24
25 my $val = $cgi->param($param);
26 $val =~ s/[\r\n]+$//;
27
28 return $val;
29}
30
31
32sub main
33{
34 my $cgi = init_cgi();
35
36 my ($gsdlhome) = usabcgi::get_config_info("gsdlhome");
37
38 my $col = clean_param($cgi,"c");
39 my $dir = clean_param($cgi,"dir");
40 $dir = "" if ($dir eq ".");
41
42 chdir "$gsdlhome/collect";
43
44 my $cmd = "zip -r $col.zip $col/$dir";
45
46
47 #print "Content-type:text/plain\n\n";
48 #print "$cmd";
49
50 my $output = `$cmd`;
51
52 ### print STDERR "**** output = $output\n";
53
54 print "Content-type:application/zip\n\n";
55## my $output2 = `cat $col.zip`;
56
57## print $output2;
58
59 if (open(PIN,"cat $col.zip |")) {
60 binmode(PIN);
61
62 my $buf;
63 my $num_bytes = 0;
64
65 while (read(PIN,$buf,1024)>0) {
66 print STDOUT $buf;
67 $num_bytes += length($buf);
68 }
69
70 close(PIN);
71
72 my $status = $?;
73 }
74
75
76
77 unlink "$col.zip";
78}
79
80&main();
81
Note: See TracBrowser for help on using the repository browser.