Last change
on this file since 25600 was 7957, checked in by davidb, 20 years ago |
Scripts revised to provide better error handline. Much of useful
functionality is bundled in gsdlCGI.pm
|
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1007 bytes
|
Line | |
---|
1 | #!/usr/bin/perl -w
|
---|
2 |
|
---|
3 | use gsdlCGI;
|
---|
4 |
|
---|
5 | sub main
|
---|
6 | {
|
---|
7 | my $gsdl_cgi = new gsdlCGI("+cmdline");
|
---|
8 |
|
---|
9 |
|
---|
10 | my $gsdlhome = $gsdl_cgi->get_config_info("gsdlhome");
|
---|
11 |
|
---|
12 | my $col = $gsdl_cgi->clean_param("c");
|
---|
13 | if (!defined $col) {
|
---|
14 | $gsdl_cgi->generate_error("No collection specified.");
|
---|
15 | }
|
---|
16 |
|
---|
17 | my $dir = $gsdl_cgi->clean_param("dir");
|
---|
18 | $dir = "" if ((!defined $dir) || ($dir eq "."));
|
---|
19 |
|
---|
20 |
|
---|
21 | $gsdl_cgi->checked_chdir("$gsdlhome/collect");
|
---|
22 |
|
---|
23 | # Change this to Java zip??
|
---|
24 | my $zip_cmd = "zip -r $col.zip $col/$dir";
|
---|
25 | $gsdl_cgi->unix_cmd($zip_cmd);
|
---|
26 |
|
---|
27 |
|
---|
28 | my $pipe_cmd = "cat $col.zip"; # Unix specific
|
---|
29 |
|
---|
30 | if (open(PIN,"$pipe_cmd |")) {
|
---|
31 | binmode(PIN);
|
---|
32 |
|
---|
33 | my $buf;
|
---|
34 | my $num_bytes = 0;
|
---|
35 |
|
---|
36 | print "Content-type:application/zip\n\n";
|
---|
37 |
|
---|
38 | while (read(PIN,$buf,1024)>0) {
|
---|
39 | print STDOUT $buf;
|
---|
40 | $num_bytes += length($buf);
|
---|
41 | }
|
---|
42 |
|
---|
43 | close(PIN);
|
---|
44 |
|
---|
45 | my $status = $?;
|
---|
46 | }
|
---|
47 | else {
|
---|
48 | $gsdl_cgi->generate_error("Unable to pipe input from: $pipe_cmd");
|
---|
49 | }
|
---|
50 |
|
---|
51 | unlink "$col.zip";
|
---|
52 | }
|
---|
53 |
|
---|
54 | &main();
|
---|
55 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.