| 1 | #!/usr/bin/env perl |
1 | #!/usr/bin/env perl |
| 2 | ################################################################################ |
2 | ################################################################################ |
| 3 | # WeBWorK Online Homework Delivery System |
3 | # WeBWorK Online Homework Delivery System |
| 4 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
4 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
| 5 | # $CVSHeader: webwork-modperl/bin/wwsh,v 1.4 2003/12/09 01:12:28 sh002i Exp $ |
5 | # $CVSHeader: webwork2/bin/wwsh,v 1.5 2004/01/03 21:00:28 sh002i Exp $ |
| 6 | # |
6 | # |
| 7 | # This program is free software; you can redistribute it and/or modify it under |
7 | # This program is free software; you can redistribute it and/or modify it under |
| 8 | # the terms of either: (a) the GNU General Public License as published by the |
8 | # the terms of either: (a) the GNU General Public License as published by the |
| 9 | # Free Software Foundation; either version 2, or (at your option) any later |
9 | # Free Software Foundation; either version 2, or (at your option) any later |
| 10 | # version, or (b) the "Artistic License" which comes with this package. |
10 | # version, or (b) the "Artistic License" which comes with this package. |
| … | |
… | |
| 21 | |
21 | |
| 22 | =cut |
22 | =cut |
| 23 | |
23 | |
| 24 | use strict; |
24 | use strict; |
| 25 | use warnings; |
25 | use warnings; |
| 26 | use FindBin; |
26 | |
| 27 | use lib "$FindBin::Bin"; |
27 | BEGIN { |
|
|
28 | die "WEBWORK_ROOT not found in environment.\n" |
|
|
29 | unless exists $ENV{WEBWORK_ROOT}; |
|
|
30 | } |
|
|
31 | |
|
|
32 | use lib "$ENV{WEBWORK_ROOT}/lib"; |
| 28 | use PSH; |
33 | use PSH; |
| 29 | use lib "$FindBin::Bin/../lib"; |
|
|
| 30 | use WeBWorK::CourseEnvironment; |
34 | use WeBWorK::CourseEnvironment; |
| 31 | use WeBWorK::DB; |
35 | use WeBWorK::DB; |
| 32 | |
36 | |
| 33 | sub main(@) { |
|
|
| 34 | my ($course, $cmd) = @_; |
37 | my ($course, $cmd) = @ARGV; |
| 35 | |
38 | |
| 36 | unless ($ENV{WEBWORK_ROOT}) { |
|
|
| 37 | die "WEBWORK_ROOT not found in environment.\n"; |
|
|
| 38 | } |
|
|
| 39 | |
|
|
| 40 | unless ($course) { |
39 | unless ($course) { |
| 41 | die "usage: $0 course\n"; |
40 | die "usage: $0 course\n"; |
| 42 | } |
41 | } |
| 43 | |
42 | |
| 44 | our $ce = WeBWorK::CourseEnvironment->new($ENV{WEBWORK_ROOT}, "", "", $course); |
43 | our $ce = WeBWorK::CourseEnvironment->new($ENV{WEBWORK_ROOT}, "", "", $course); |
| 45 | our $db = WeBWorK::DB->new($ce->{dbLayout}); |
44 | our $db = WeBWorK::DB->new($ce->{dbLayout}); |
| 46 | (undef) = $db; # placate warnings |
45 | (undef) = $db; # placate warnings |
| 47 | |
46 | |
| 48 | if ($cmd) { |
47 | if ($cmd) { |
| 49 | no warnings; |
48 | no warnings; |
| 50 | no strict; |
49 | no strict; |
| 51 | eval $cmd; |
50 | eval $cmd; |
| 52 | die $@ if $@; |
51 | die $@ if $@; |
| 53 | use strict; |
52 | use strict; |
| 54 | use warnings; |
53 | use warnings; |
| 55 | } else { |
54 | } else { |
| 56 | print <<'EOF'; |
55 | print <<'EOF'; |
| 57 | wwsh - The WeBWorK Shell |
56 | wwsh - The WeBWorK Shell |
| 58 | Available objects: $ce (WeBWorK::CourseEnvironment) |
57 | Available objects: $ce (WeBWorK::CourseEnvironment) |
| 59 | $db (WeBWorK::DB) |
58 | $db (WeBWorK::DB) |
| 60 | EOF |
59 | EOF |
| 61 | PSH::prompt(); |
60 | PSH::prompt(); |
| 62 | } |
|
|
| 63 | } |
61 | } |
| 64 | |
|
|
| 65 | main(@ARGV); |
|
|