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?

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .