Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,17 @@ if [ "$FILE_EXTENSION" == "c" ]; then
clang -o output_program "$CODE_FILE" 2> compile_error.txt
elif [ "$FILE_EXTENSION" == "cpp" ]; then
clang++ -o output_program "$CODE_FILE" 2> compile_error.txt
else
echo "Invalid language specified! Use 'c' or 'cpp'."
exit 1
fi

# Check if there were any compilation errors
if [ $? -ne 0 ]; then
echo -e "Compilation failed!\n"
cat compile_error.txt
exit 1
fi
# Run the compiled program and capture runtime errors
./output_program > output.txt 2> runtime_error.txt

# Check if there were any runtime errors
if [ $? -ne 0 ]; then
echo -e "Runtime error!\n"
cat runtime_error.txt
exit 1

fi
# start
if [ -f "/usr/src/app/cpp-engine/app/input.txt" ]; then
# Run the compiled program with input redirection
Expand All @@ -42,6 +36,7 @@ else
fi
# end
if [ $? -ne 0 ]; then
echo -e "Runtime error occurred!\n"
cat runtime_error.txt
exit 1
fi
Expand Down
31 changes: 1 addition & 30 deletions js.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1 @@
#!/bin/bash

# Path to the Python file to run
INPUT_REQUIRED=false

# Check for the flag (modify if using a different flag name)
if [[ "$1" == "inputtrue" ]]; then
INPUT_REQUIRED=true
shift # Remove the flag from the argument list
fi


CODE_FILE="/usr/src/app/js-engine/app/index.js"


if [[ $INPUT_REQUIRED == true ]]; then

nodejs $CODE_FILE < /usr/src/app/js-engine/app/input.txt > output.txt 2> runtime_error.txt

else
nodejs $CODE_FILE > output.txt 2> runtime_error.txt
fi

if [ $? -ne 0 ]; then
echo "Runtime error!"
cat runtime_error.txt
exit 1
fi

cat output.txt
No code provided