当前位置:网站首页>Shell programming core technology "four"
Shell programming core technology "four"
2022-07-04 19:24:00 【Wu_ Candy】
The content shared today is similar to Shell Programming core technology 《 3、 ... and 》 It's linked , It needs to be read together .
function
Next , We package it into a tester_level function , After having functions, they can be called at any time during the execution process to realize function encapsulation and logic reuse .
You can see from the picture above , call test_001.sh Script and pass in a parameter :java, It didn't output what we expected java auto tester, The reason is that only defining functions will not be implemented , For example, no relevant information is output at this time auto tester result .
And we run tester_level Function and will 2 Pass parameters to it , here 2 Is the second parameter of the script , But it is tester_level First argument to function .
Execute the script , Pass in a parameter java, No display , One more python Still no response , Until incoming python java After two parameters , Just output java auto tester, because tester_level The second parameter of the whole script is received .
Permission bit execution Shell Script
Through the demonstration of the previous case, we have mastered the use sh Execute the script , But if we Do not want to use sh Execute the script , If you want the system to parse automatically , It can be realized by weighted limit .
First of all to see test_001.sh What is the current permission bit of , You can use commands :ls -l /tmp/test_001.sh, As shown in the figure above , It can be found that there is no x, That is, there is no executable permission .
When we directly enter the command :/tmp/test_001.sh, namely test_001.sh When the full path of the file is , Wrong presentation :Permission denied No execution permission .
As shown in the figure above , Use command :chmod +x /tmp/test_001.sh Add executable permissions to files .
As shown in the figure above , When no document is given test_001.sh When adding executable permissions to a file , Direct use command :/tmp/test_001.sh It's a newspaper permission denied Wrong , But when you add executable permissions to the file , Use the command again :/tmp/test_001.sh When executing a script , It can be executed successfully , No report error .
add to PATH Variable fast execution Shell Script
If test_001.sh The full path of the file is very long , Such as /user/candy/python/shell/project_person_tmp/test_001.sh, We want to execute test_001.sh file , Follow the method described above , Need to enter test_001.sh The full path of the file can be executed , This is too complicated , Remember clearly every time you execute test_001.sh The full path of the file and enter , Is there a simpler way , If you only enter the file name :test_001.sh You can run the script directly ? The answer is yes .
The solution is : take /tmp This path adds to PATH variable , Enter test_001.sh If the command is executed directly, there will be no more errors .
Shell Debug during script execution
When our Shell The script is wrong , How to debug during execution ?
As shown in the figure above , have access to sh -x command , It can print every command line of the current script when the script is running , When the script goes wrong, you can know which line went wrong , It passes by + The output at the beginning shows which line is currently being executed Shell Code , With it, debugging becomes very convenient .
Friendship tips :“ The way of immeasurable testing ” Original works , Welcome to exchange , It is forbidden for a third party to reprint the article without displaying its source .
边栏推荐
- Scala basic tutorial -- 14 -- implicit conversion
- Shell 编程核心技术《三》
- LeetCode 赎金信 C#解答
- [release] a tool for testing WebService and database connection - dbtest v1.0
- [发布] 一个测试 WebService 和数据库连接的工具 - DBTest v1.0
- Scala basic tutorial -- 18 -- set (2)
- How to modify icons in VBS or VBE
- 26. 删除有序数组中的重复项 C#解答
- Scala基础教程--16--泛型
- Is Guoyuan futures a regular platform? Is it safe to open an account in Guoyuan futures?
猜你喜欢

使用canal配合rocketmq监听mysql的binlog日志

Scala basic tutorial -- 20 -- akka

奥迪AUDI EDI INVOIC发票报文详解

神经网络物联网应用技术学什么
Summary and sorting of 8 pits of redis distributed lock

升级智能开关,“零火版”、“单火”接线方式差异有多大?
![[go ~ 0 to 1] read, write and create files on the sixth day](/img/cb/b6785ad7d7c7df786f718892a0c058.png)
[go ~ 0 to 1] read, write and create files on the sixth day

LM10丨余弦波动顺势网格策略

Build your own website (15)

与二值化阈值处理相关的OpenCV函数、方法汇总,便于对比和拿来使用
随机推荐
Have you guys ever used CDC direct Mysql to Clickhouse
Build your own website (15)
使用canal配合rocketmq监听mysql的binlog日志
从实时应用角度谈通信总线仲裁机制和网络流控
2022-07-04: what is the output of the following go language code? A:true; B:false; C: Compilation error. package main import 'fmt' func
问下各位大佬有用过cdc直接mysql to clickhouse的么
Caché JSON 使用JSON适配器
Nebula importer data import practice
基于NCF的多模块协同实例
Shell 编程核心技术《二》
From automation to digital twins, what can Tupo do?
Other InterSystems%net tools
Nature microbiology | viral genomes in six deep-sea sediments that can infect Archaea asgardii
工厂从自动化到数字孪生,图扑能干什么?
添加命名空间声明
大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
[opencv introduction to mastery 9] opencv video capture, image and video conversion
In flinksql, in addition to data statistics, is the saved data itself a state
Unity给自己的脚本添加类似编辑器扩展的功能案例ContextMenu的使用
2022-07-04:以下go语言代码输出什么?A:true;B:false;C:编译错误。 package main import 'fmt' func