Skip to content

Commit 2851dd1

Browse files
Verify on command line, exit code of bash script to hit server with curl.
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" expected output: radsauce it worked
1 parent ef09f3e commit 2851dd1

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

verifyscript.sh

+22-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
#!/bin/bash
22

3+
#terminal 1: run PORT=3100 node app.js
4+
#expected output after terminal 2 curl's:
5+
#radsauce
6+
7+
#terminal 2: ./verifyscript.sh && echo "it worked" || echo "fail"
8+
#expected output:
9+
# radsauce
10+
# it worked
11+
312
OUTPUT="$(curl --request POST -d radsauce http://localhost:3100/foo -H "Content-Type: text/plain" 2>/dev/null )"
413

514
echo "${OUTPUT}"
6-
#
7-
if [ "${OUTPUT}" = "radsauce" ];
815

9-
then
1016

11-
echo "gimme things 'cause it's the same: OUTPUT is ${OUTPUT}";
17+
if [ "${OUTPUT}" = "radsauce" ]; then
1218

13-
fi
19+
#this next line is unnecessary, just exists to clarify purpose:
20+
echo "success, child process exit code 0: OUTPUT is ${OUTPUT}";
21+
22+
exit 0;
1423

15-
#else
16-
#echo "nope failure";
24+
else
25+
26+
#this next line is unnecessary, just exists to clarify purpose:
27+
echo "failure, child process exit code 1: OUTPUT is ${OUTPUT}";
28+
29+
exit 1;
30+
31+
fi

0 commit comments

Comments
 (0)