Q:

Feeding User Input using bash script

I have a java program where I am expecting user to give some input and I want to use bash script to test the program. Though the program is working fine but I am not able to pass user input using script.
javac -d build ParkingLot.java
cd build/
java ParkingLot
"create_parking_lot 5"
"park hy-25-ysud-23 red"
"park hy-25-gfvd-23 white"
"park hy-25-ysfd-23 green"
"park hy-25-ysfd-24 black"
"park hy-25-ysfd-25 green"
"park hy-25-asfd-23 white"
"exit"

This 8 strings at the end is my input to program. How do I do this?

A:

You can try Bash's here-document (one form of input redirection) in the script:
java ParkingLot << END
create_parking_lot 5
park hy-25-ysud-23 red
park hy-25-gfvd-23 white
park hy-25-ysfd-23 green
park hy-25-ysfd-24 black
park hy-25-ysfd-25 green
park hy-25-asfd-23 white
exit
END

