The command read is used in scripting to accept a value for a variable from the user.
The default operation of read is to wait infinetly for the user to enter a value. This behavour can be changed and read can be made to wait for a specific time only and abort after that.
This can be done by using the option "-t" with read i.e.
This will make read to wait for 5 seconds before aborting.
The script below shows how to use the option.
read_timeout.sh
The above script waits for 5 seconds for the user to enter a value,if the user fails to do so the script will continue to run and throw an error message.
Save it,give it execute permissions and execute it
If we do not enter any value at the read prompt, after 5 seconds we should see the following message.
Output:
The default operation of read is to wait infinetly for the user to enter a value. This behavour can be changed and read can be made to wait for a specific time only and abort after that.
This can be done by using the option "-t" with read i.e.
This will make read to wait for 5 seconds before aborting.
The script below shows how to use the option.
read_timeout.sh
The above script waits for 5 seconds for the user to enter a value,if the user fails to do so the script will continue to run and throw an error message.
Save it,give it execute permissions and execute it
If we do not enter any value at the read prompt, after 5 seconds we should see the following message.
Output:
The post is absolutely fantastic! Lots of great information and inspiration both of which we all need! Also like to admire the time and effort you put into your blog and detailed information you offer! I will bookmark your blog!
ReplyDeleteScarprin Information
Well I am so excited that I have found your post because I have been searching for some information on this for almost three hours! You've helped me a lot indeed and by reading this article I have found many new and useful information about this subject!
ReplyDeletewe buy houses
It seems that everybody is into this kind of stuff lately. Don’t really understand it though but thanks for trying to explain it. Appreciate you shedding light into this matter. Keep up your work.
ReplyDeletebusiness information
The tech related blog of Linux World is describing about read timeout in scripting. This is term is very essential in the time of operating this Linux Operating System. So admin is perfect for getting praise.
ReplyDeleteDrupal
how to configure DNS server
ReplyDeleteشيخة اماراتية