test.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/sh
  2. # g.parser demo script for shell programming
  3. #%module
  4. #% description: g.parser test script (shell)
  5. #% keyword: keyword1
  6. #% keyword: keyword2
  7. #%end
  8. #%flag
  9. #% key: f
  10. #% description: A flag
  11. #%end
  12. #%option G_OPT_R_MAP
  13. #% key: raster
  14. #% required: yes
  15. #%end
  16. #%option G_OPT_V_MAP
  17. #% key: vector
  18. #%end
  19. #%option
  20. #% key: option1
  21. #% type: string
  22. #% description: An option
  23. #% required: no
  24. #%end
  25. if [ -z "$GISBASE" ] ; then
  26. echo "You must be in GRASS GIS to run this program." 1>&2
  27. exit 1
  28. fi
  29. if [ "$1" != "@ARGS_PARSED@" ] ; then
  30. exec g.parser "$0" "$@"
  31. fi
  32. #### add your code below ####
  33. echo ""
  34. if [ $GIS_FLAG_F -eq 1 ] ; then
  35. g.message message="Flag -f set"
  36. else
  37. g.message message="Flag -f not set"
  38. fi
  39. # test if parameter present:
  40. if [ -n "$GIS_OPT_OPTION1" ] ; then
  41. echo "Value of GIS_OPT_OPTION1: '$GIS_OPT_OPTION1'"
  42. fi
  43. g.message message="Value of GIS_OPT_option1: '$GIS_OPT_option1'"
  44. g.message message="Value of GIS_OPT_raster: '$GIS_OPT_raster'"
  45. g.message message="Value of GIS_OPT_vect: '$GIS_OPT_vector'"
  46. #### end of your code ####