-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverifyscript.sh
More file actions
executable file
·40 lines (28 loc) · 1.05 KB
/
verifyscript.sh
File metadata and controls
executable file
·40 lines (28 loc) · 1.05 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
#!/bin/bash
#terminal 1: run PORT=3100 node app.js
#expected output after terminal 2 curl's:
#radsauce
#terminal 2: ./verifyscript.sh && echo "it worked" || echo "fail" etc
#
# Specific command to run in terminal 2 is:
#
# ( ./verifyscript.sh && if [ $? -lt 0 ];
# then echo "failure, exit code -1";
# elif [ $? -eq 0 ]; then echo "success, exit code 0";
# elif [ $? -lt 0 ]; then echo "failure, exit code less than 1";
# elif [ $? -gt 1 ]; then echo "exit code greater than 1"; fi )
# radsauce
# success, child process exit code 0: OUTPUT is radsauce
OUTPUT="$(curl --request POST -d radsauce http://localhost:3100/foo -H "Content-Type: text/plain" 2>/dev/null )"
echo "${OUTPUT}"
# possible alternative:
# if [ $? -eq 0 ]; then
if [ "${OUTPUT}" = "radsauce" ]; then
#this next line is unnecessary, just exists to clarify purpose:
echo "success, child process exit code 0: OUTPUT is ${OUTPUT}";
exit 0;
else
#this next line is unnecessary, just exists to clarify purpose:
echo "failure, child process exit code 1: OUTPUT is ${OUTPUT}";
exit 1;
fi