10_2c_1d_2p_pub_export 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. printf "$PRINTFPATTERN" $0 : "2 Compilations. 1 Dossier. 2 Projets. Pad Public. export/txt"
  3. URL_BASE=https%3A%2F%2Fpad.exegetes.eu.org%2Fp%2Fg.DSXI1kGFT1gjor66%24Abro-REP-Tele2-Principal%2Fexport%2Ftxt
  4. URL_GARDE=https%3A%2F%2Fpad.exegetes.eu.org%2Fp%2Fg.DSXI1kGFT1gjor66%24Abro-REP-Tele2-Garde%2Fexport%2Ftxt
  5. DOSSIER=MonDossier$$
  6. PROJET1=Abro2$$
  7. PROJET2=Abro3
  8. # pids conserve la liste des pids
  9. # retcode conserve le code retour de chaque pid une fois terminé
  10. handle_child() {
  11. local tmp=()
  12. for((i=0;i<${#pids[@]};++i));
  13. do
  14. if test ! -d /proc/${pids[i]};
  15. then
  16. wait ${pids[i]}
  17. retcode[${pids[i]}]=$?
  18. else
  19. tmp+=(${pids[i]})
  20. fi
  21. done
  22. pids=(${tmp[@]})
  23. }
  24. set -o monitor
  25. trap "handle_child" CHLD
  26. # Start background processes
  27. OUTPUT1=$(./cocktail -v \
  28. -d "$DOSSIER" \
  29. -p "$PROJET1" \
  30. -b "$URL_BASE" \
  31. -g "$URL_GARDE" 2>&1 >/dev/null) &
  32. pids+=($!)
  33. OUTPUT=$(printf "%s\n%s" "$OUTPUT" "START $!")
  34. OUTPUT2=$(./cocktail -v \
  35. -d "$DOSSIER" \
  36. -p "$PROJET2" \
  37. -b "$URL_BASE" \
  38. -g "$URL_GARDE" 2>&1 >/dev/null) &
  39. pids+=($!)
  40. OUTPUT="START $!"
  41. # Wait until all background processes are stopped
  42. while [ ${#pids[@]} -gt 0 ];
  43. do
  44. OUTPUT=$(printf "%s\n%s %s %s" "$OUTPUT" "WAITING FOR: "${pids[@]})
  45. sleep 4;
  46. done
  47. OUTPUT=$(printf "%s\n%s" "$OUTPUT" "STOPPED")
  48. # affichage des code retour et generation de la chaine de test
  49. for pid in "${!retcode[@]}"
  50. do
  51. statusstring="$statusstring $pid=${retcode[$pid]}"
  52. retcodestr="${retcodestr}${retcode[$pid]}"
  53. done
  54. echo -n "RC $statusstring "
  55. if test "$retcodestr" -eq "00";
  56. then
  57. echo "[ OK ]"
  58. echo "$OUTPUT"
  59. exit 0
  60. else
  61. echo "[FAILED]"
  62. echo "$OUTPUT"
  63. exit 1
  64. fi