✅ Executing bash script in docker container with Docket.DotNet in ASP.NET website
So i need to run some script in docker container and the container crashes instantly and logs are:
I'm using Gcc:Latest docker image
The script:
bash: line 56: ./ExaminationFile.sh: cannot execute: required file not foundbash: line 56: ./ExaminationFile.sh: cannot execute: required file not foundI'm using Gcc:Latest docker image
Cmd = new List<string>
{
"bash",
"-c",
$"echo '{examinationFileAsString}' > ExaminationFile.sh && " +
$"chmod 777 ExaminationFile.sh && " +
$"ls -l > lsOutput.txt && " +
$"pwd > pwdOutput.txt && " +
$"./ExaminationFile.sh > testCount.txt"
}, Cmd = new List<string>
{
"bash",
"-c",
$"echo '{examinationFileAsString}' > ExaminationFile.sh && " +
$"chmod 777 ExaminationFile.sh && " +
$"ls -l > lsOutput.txt && " +
$"pwd > pwdOutput.txt && " +
$"./ExaminationFile.sh > testCount.txt"
},The script:
#!/bin/bash
getNumTests() {
echo 5
}
getTestInput() {
local test_index=$1
case $test_index in
0) echo "5 10 8 15 3 6";;
1) echo "2 4 7 9 1";;
2) echo "10 20 30";;
3) echo "100 50 75";;
4) echo "3 6 9 12";;
*) echo "";;
esac
}
getMemoryTimeLimits() {
local test_index=$1
case $test_index in
0) echo "128 1000";;
1) echo "64 500";;
2) echo "256 1500";;
3) echo "512 2000";;
4) echo "32 300";;
*) echo "0 0";;
esac
}
getCorrectOutput() {
local test_index=$1
case $test_index in
0) echo "15";;
1) echo "9";;
2) echo "30";;
3) echo "100";;
4) echo "12";;
*) echo "0";;
esac
}
# Main script logic
if [[ $# -eq 0 ]]; then
getNumTests
elif [[ $1 == "P" && $# -eq 2 ]]; then
getMemoryTimeLimits $2
elif [[ $1 == "R" && $# -eq 2 ]]; then
getCorrectOutput $2
elif [[ $1 =~ ^[0-9]+$ ]]; then
getTestInput $1
else
echo "Invalid arguments"
exit 1
fi#!/bin/bash
getNumTests() {
echo 5
}
getTestInput() {
local test_index=$1
case $test_index in
0) echo "5 10 8 15 3 6";;
1) echo "2 4 7 9 1";;
2) echo "10 20 30";;
3) echo "100 50 75";;
4) echo "3 6 9 12";;
*) echo "";;
esac
}
getMemoryTimeLimits() {
local test_index=$1
case $test_index in
0) echo "128 1000";;
1) echo "64 500";;
2) echo "256 1500";;
3) echo "512 2000";;
4) echo "32 300";;
*) echo "0 0";;
esac
}
getCorrectOutput() {
local test_index=$1
case $test_index in
0) echo "15";;
1) echo "9";;
2) echo "30";;
3) echo "100";;
4) echo "12";;
*) echo "0";;
esac
}
# Main script logic
if [[ $# -eq 0 ]]; then
getNumTests
elif [[ $1 == "P" && $# -eq 2 ]]; then
getMemoryTimeLimits $2
elif [[ $1 == "R" && $# -eq 2 ]]; then
getCorrectOutput $2
elif [[ $1 =~ ^[0-9]+$ ]]; then
getTestInput $1
else
echo "Invalid arguments"
exit 1
fi
