Link to home
Start Free TrialLog in
Avatar of John Sheehy
John SheehyFlag for United States of America

asked on

Adding a continue option in a script

So my script does many things and it does them rather fast thanks to all that have helped out over the past two days.  I would like to pause the script and allow the user to hit Y to continue is this possible and if so, how?

Thanks
John
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

If it has to be an uppercase "Y" add in the appropriate place:

A="N"
while [[ $A != "Y" ]]
  do
     read A
  done

Otherwise (if it can be any character or even just the <Enter> key) a simple

read A

would suffice.
Avatar of John Sheehy

ASKER

I would love it to say the following:

Press Y to to continue or X to Exit...

And then they press the appropriate key.

Does that make better sense?

Thanks
John
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The "read" statement under ksh would look like this:

read A?"Press Y to to continue or X to Exit..."

All other stuff can remain the same.
OK, I will try it out and let you know within 30 min.
I am getting the following error:

[[N!=Y]]: not Found

Thoughts?

John
The variables/strings must be separated from the double square brackets as well as from the comparison operator by spaces:

[[ $A != "Y" ]]
Ok, Ill give that a try.  Thanks
The solution worked out great.  Sorry it took so long to respond.