forked from CIS380/gists
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.sh
More file actions
executable file
·44 lines (40 loc) · 860 Bytes
/
validate.sh
File metadata and controls
executable file
·44 lines (40 loc) · 860 Bytes
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
#!/bin/bash
set +e
SHREDDER=$1
IN='./input_pipe'
OUT='./output_pipe'
close_pipes() {
exec 5>&-
exec 6>&-
rm -f "$IN";
rm -f "$OUT";
}
create_pipes() {
mkfifo "$IN";
mkfifo "$OUT";
}
open_pipes() {
exec 5>$IN;
exec 6<$OUT;
}
close_pipes
create_pipes
$SHREDDER $timeout < $IN >> $OUT &
pid=$! #gets shredders pid
open_pipes
echo '/bin/pwd' >&5
if ! read -u6 -t 2 RESP; then
echo "Timeout on response from shredder"
exit 1;
fi
expected="shredder# $($'/bin/pwd')"
if [[ $RESP != $expected ]]; then
echo "Response did not match"
echo "expected :$expected"
echo "actual :$RESP"
echo "This only is comparing the output of stdout. If the spacing looks wrong check the whitespace after the prompt text."
exit 1;
fi
disown $pid &> /dev/null && kill -9 $pid &> /dev/null
close_pipes
echo "Spacing is ok"