Skip to content

Commit

Permalink
continue regex exercice
Browse files Browse the repository at this point in the history
  • Loading branch information
romaincarlier4 committed Oct 26, 2023
1 parent 6f4e536 commit 94d58b3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
37 changes: 15 additions & 22 deletions Regex/run
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
#!/bin/bash

getinput regex1 > student/student_code.sh
tr -d '\r' < student/student_code.sh > student/tmp
mv student/tmp student/student_code.sh
cp ./buggy.sh ./student/buggy.sh
getinput regex1 | tr -d '\r' > student/student_regex1
getinput regex2 | tr -d '\r' > student/student_regex2
getinput regex3 | tr -d '\r' > student/student_regex3
getinput regex4 | tr -d '\r' > student/student_regex4
cp apache.log student/

regex1=$(cat student_regex1)
regex2=$(cat student_regex2)
regex3=$(cat student_regex3)
regex4=$(cat student_regex4)

if grep -q -E "cd|ls|cat" ./student/student_code.sh; then
feedback-result failed
feedback-msg -em "Vous n'avez pas besoin d'utiliser la commande cd, ls ou cat"
exit 0
fi

chmod +x ./student/buggy.sh
cd student
output=$(run_student sh ./student_code.sh)

if [[ -f "./args_err.txt" ]]; then
feedback-result failed
feedback-msg -em "Attention, le script buggy.sh prend comme argument un nombre entier"
exit 0
fi
output1=$(grep -oP $regex1 apache.log)
good_output1=$(grep -oP '(\d{1,3}\.){3}\d{1,3}' apache.log)

if [ "$output" = "42" ]; then
feedback-result success
feedback-msg -em "Bravo, le nombre qui posait problème était bien 42."
if [ $output1==$good_output1 ]; then
feedback-result --id regex1 success
feedback-msg -em "Bravo"
else
feedback-result failed
feedback-msg -em "Résultat de votre programme : $output"
feedback-msg -em "Résultat de votre programme : $output1"
fi
10 changes: 5 additions & 5 deletions Regex/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ network_grading: false
problems:
regex1:
type: code
name: Exercice 1 - addresses IP
name: addresses IP
header: Insérez ici votre regex pour extraire toutes les addresses IP
language: bash
default: .*
regex2:
type: code
name: Exercice 2 - timestamps
name: timestamps
header: Insérez ici votre regex pour extraire tous les timestamps
language: bash
default: .*
regex3:
type: code
name: Exercice 3 - GET requests
name: GET requests
header: Insérez ici votre regex pour extraire toutes les requêtes GET
language: bash
default: .*
regex3:
regex4:
type: code
name: Exercice 4 - Successful GET requests
name: Successful GET requests
header: Insérez ici votre regex pour extraire toutes les requêtes GET qui ont un code de retour 200
language: bash
default: .*

0 comments on commit 94d58b3

Please sign in to comment.