-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeworld-upload_mac.pl
More file actions
executable file
·41 lines (35 loc) · 1.07 KB
/
codeworld-upload_mac.pl
File metadata and controls
executable file
·41 lines (35 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env perl
use strict;
use warnings;
use Term::ANSIColor;
my $mode = "codeworld";
my $url = "https://blackeyepeas.phys.lsu.edu/cw/";
my $file = $ARGV[0];
print "Uploading $file ...\n";
my $json = `curl -S -s -F "mode=$mode" -F "source=<$file" ${url}compile`;
my $dhash = `echo '$json' | jq -r .dhash`;
my $hash = `echo '$json' | jq -r .hash`;
chomp($dhash);
chomp($hash);
my $errormsg = `curl -S -s -F "mode=$mode" -F "hash=$hash" ${url}runMsg`;
if ($errormsg eq "" or index($errormsg, "error") == -1) {
my $curl = "$url#$hash";
my $durl = "${url}run.html?mode=$mode&dhash=$dhash";
print color("green");
print("Successfully uploaded files!\n");
print color("reset");
print("Source at: $curl\n");
print("Runnable at: $durl\n");
if ($errormsg ne "") {
print color('yellow');
print("Compiled with warnings:\n");
print("$errormsg\n");
print color('reset');
}
exec("open \'$durl\'");
} else {
print color("red");
print("\nCompilation failed:\n");
print("${errormsg}\n");
print color("reset");
}