-
Notifications
You must be signed in to change notification settings - Fork 0
/
evalcmd
executable file
·50 lines (41 loc) · 1.08 KB
/
evalcmd
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
42
43
44
45
46
47
48
#!/bin/bash
# Preloading. This is really just necessary because the author's VPS can have
# a significant delay when reading non-cached files.
cat hda &> /dev/null
expandtab() {
awk '{
while(match($0, /\t/)) {
s=(int((RSTART-1)/8)+1)*8-RSTART+1;
r=sprintf("% " s "s", "");
$0=substr($0, 0, RSTART-1) r substr($0, RSTART+1);
}
print;
} '
}
output=$(./limitcmd.pl "$1" | head -c 4242 | tr -d '\r' | expandtab | awk '{ do { print substr($0, 1, 120); $0 = substr($0, 121); } while(length($0)>0); }'; exit ${PIPESTATUS[0]}; )
result=$?
lines=$(wc -l <<< "$output")
shopt -s extglob
if [[ $output == *( ) ]]
then
if (( $result > 0 ))
then
echo "no output within the time limit"
else
echo "no output"
fi
exit 0
fi
if (( $lines <= 3 )); then
printf "%s\n" "$output";
exit 0
fi
url=$(./paste <<< "$output")
if [[ -n $url ]]
then
etc="etc... ( $url )"
else
etc="and so forth... (but now the pastebin is sick of me)"
fi
printf "%s\n" "$output" | head -n 2
echo "$etc"