当前位置:网站首页>How can a shell script (.Sh file) not automatically close or flash back after execution?

How can a shell script (.Sh file) not automatically close or flash back after execution?

2022-06-24 12:15:00 Dust_ Evc

Shell The script is very proud , When something goes wrong 、 After the implementation, you will not be given a chance to view the error information 、 Output information , Go straight back .

I don't say much nonsense , The training method is as follows , Directly in Shell Add the following code to the end of the script

#   Use read The command achieves something similar bat Medium pause Command effect 
echo  Press any key to continue 
read -n 1
echo  Continue operation 

example :

some .sh The file contents are shown below , Directly flash back after execution or error .

Add the code at the end :

such , After running error 、 After execution , You can have enough time to view the error message 、 Output information . Press any key to close the window or click close window .

in addition , utilize sleep Command to realize window delay closing and other examples can be referred to :

https://blog.csdn.net/ouyang_peng/article/details/113568009

原网站

版权声明
本文为[Dust_ Evc]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240953157593.html