Changeset 4232
- Timestamp:
- 2003-05-07T15:49:26+12:00 (21 years ago)
- Location:
- trunk/gsdl/bin/script
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/picklanguage.pl
r4125 r4232 32 32 33 33 BEGIN { 34 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'}; 34 if (!defined($ENV{'GSDLHOME'})) { 35 print STDERR "GSDLHOME not set\n"; 36 return 1; 37 } 35 38 unshift (@INC, "$ENV{'GSDLHOME'}/perllib"); 36 39 } … … 44 47 { 45 48 my $gsdldir = "$ENV{'GSDLHOME'}"; 46 47 49 # Read the languages available from etc/main.cfg 48 50 my $maincfg_fname = util::filename_cat($gsdldir, "etc", "main.cfg"); 49 open(MCFILE, "<$maincfg_fname") or die "Error: Could not open $maincfg_fname: $!\n"; 51 if (!open(MCFILE, "<$maincfg_fname")) { 52 print STDERR "Error: Could not open $maincfg_fname: $!\n"; 53 return 2; 54 } 50 55 51 56 my @languages; … … 63 68 64 69 # Write the HTML content of the page to tmp/lang/picklanguage.lang 65 my $picklang_fname = util::filename_cat($gsdldir, "tmp", "lang", "picklanguage.lang"); 70 my $dir = util::filename_cat($gsdldir, "tmp", "lang"); 71 # creates directory if it doesn't already exist 72 my $currentmask = umask; 73 umask(0000); 74 if (!-e $dir) { 75 if (! mkdir($dir, 0777)) { 76 print STDERR "Couldn't create directory $dir\n"; 77 return 3; 78 } 79 } 80 my $picklang_fname = util::filename_cat($dir, "picklanguage.lang"); 66 81 67 82 # Make the file world writeable 68 my $currentmask = umask;69 umask(0000);70 83 if (! open(HTMLFILE,">$picklang_fname")) { 71 84 umask($currentmask); 72 die "Error: Could not create $picklang_fname: $!\n"; 85 print STDERR "Error: Could not create $picklang_fname: $!\n"; 86 return 4; 73 87 } 74 88 umask($currentmask); … … 99 113 "<center><img src=\"_httpimg_/divb.gif\"></center><p>"); 100 114 close HTMLFILE; 115 return 0; 101 116 } 102 117 103 118 104 &main();119 exit &main(); -
trunk/gsdl/bin/script/translator.pl
r4179 r4232 29 29 30 30 BEGIN { 31 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'}; 31 if (!defined $ENV{'GSDLHOME'}) { 32 print STDERR "GSDLHOME not set\n"; 33 return 1; 34 } 32 35 unshift (@INC, "$ENV{'GSDLHOME'}/perllib"); 33 36 } … … 55 58 # Check that both arguments were supplied 56 59 if (!$sourcelang) { 57 die "Error: You didn't supply the name of the source language!\n"; 60 print STDERR "Error: You didn't supply the name of the source language!\n"; 61 return 2; 58 62 } 59 63 if (!$targetlang) { 60 die "Error: You didn't supply the name of the target language!\n"; 64 print STDERR "Error: You didn't supply the name of the target language!\n"; 65 return 2; 61 66 } 62 67 … … 73 78 if (! -e $translationdir) { 74 79 print STDERR "Error: Translation has not been initialised (exiting).\n"; 75 return ;80 return 3; 76 81 } 77 82 … … 84 89 # Make sure some macros exist to be translated 85 90 if (!$sourcehash1 && !$sourcehash2) { 86 die "Error: No source macro information exists.\n"; 91 print STDERR "Error: No source macro information exists.\n"; 92 return 4; 87 93 } 88 94 … … 372 378 # Write the number of pages to a file for use by the receptionist 373 379 my $numpagesfile = util::filename_cat($translationdir, "numpages.log"); 374 open NUMPAGESLOG, ">$numpagesfile" or die "Error: Could not write $numpagesfile.\n"; 380 if (!open NUMPAGESLOG, ">$numpagesfile") { 381 print STDERR "Error: Could not write $numpagesfile.\n"; 382 return 5; 383 } 375 384 print NUMPAGESLOG ($pageno - 1); 376 385 close NUMPAGESLOG; … … 378 387 # Write thankyou page for language translator once translation is complete 379 388 my $thankyoufile = util::filename_cat($translationdir, "thankyou.lang"); 380 open THANKYOU, ">$thankyoufile" or die "Error: Could not write $thankyoufile.\n"; 389 if (!open THANKYOU, ">$thankyoufile") { 390 print STDERR "Error: Could not write $thankyoufile.\n"; 391 return 6; 392 } 381 393 print THANKYOU ("<center> _textthanks_ $targetlang _texttrans_ ", 382 394 "<br> _textviewtranslation_ ", … … 614 626 } 615 627 616 617 &main(@ARGV); 628 exit &main(@ARGV);
Note:
See TracChangeset
for help on using the changeset viewer.