0

My script is called: report_startDate

It has the following line:

$JRE_ROOT/bin/java -cp /home/me/report/config/:/home/me/report/jar/reporting-1.0-SNAPSHOT.jar  com.me.project.report.Main $1

$1 makes it possible to for me to run the script as: ./report_startDate 20140717.

But the script also runs without the date. I want to make it mandatory for whoever runs this script to supply the date.

What could I replace $1 with to make it mandatory to supply date?

Kevdog777
  • 3,194
  • 18
  • 43
  • 64
M06H
  • 103
  • 3

1 Answers1

1

Put this at the top:

if [ -z "$1" ]; then
    echo "Argument required."
    exit
fi 

-z tests the argument string to see if it is of zero length.

If it's not zero length, execution will continue.

goldilocks
  • 86,451
  • 30
  • 200
  • 258