Linux (11)

Source: Internet
Author: User
Tags logical operators

# # #代理 # #
# #正向代理 # #
The client cannot access the server side, and the proxy accesses the server-side cache data for the client to see.
This experiment:
Client ip:172.25.27.227
Agent machine two x ip:172.25.254.127 172.25.27.127
Service-Side ip:172.25.254.27
Steps:
(1) Agent installs and configures squid
[email protected] ~]# yum install squid-y # #安装软件
[Email protected] ~]# vim/etc/squid/squid.conf # #修改配置文件
Http_access Allow all #允许所有人访问代理
Http_port 3128 #访问代理使用端口3128
Cache_dir Ufs/var/spool/squid # #缓存空间100M, 16-level directories, 256 two-level directories for easy caching
(2) Service side
[Email protected] ~]# echo 172.25.254.27 >/var/www/html/index.html # #修改默认发布文件
[Email protected] ~]# systemctl start httpd # #开启服务
(3) client browser configuration
HTTP proxy:172.25.254.127 port:3128


# #反向代理 # #
Agent configuration, client browser directly access the agent, do not do other things
(1) Agent configuration file modification
[Email protected] ~]# vim/etc/squid/squid.conf
Http_access Allow all
Http_port Vhost Vport
Cache_peer 172.25.254.27 Parent 0 proxy-only
Cache_dir UFS/VAR/SPOOL/SQUID 100 16 256
[Email protected] squid]# systemctl restart Squid
(2) Browser



# # #脚本 # #
1. Script Debug mode
Bash-x scripts
2. References and Escapes
Weak references: "string", preserving literal values of string characters, variables and extended commands still function within double quotes $ ' \! Except
Strong reference: ' String ', preserves string all character literal values, disables all extensions
Escape: \ Preserves the literal value of the next character
3. Variables
Use a fixed character to represent a value that is not fixed
Set System Variables
Vim/etc/profile
Source/etc/profile
Set User Variables
CD ~
Vim. Bash_profile
source. bash_profile
Setting environment variables
Environment variables: Variables that pass content to a child process
Display all environment variables using the ENV command
Export variable =
4.shell calculation commands
(1) $[] denotes mathematical operations
[[email protected] squid]# echo $[7+2]
9
(2) expr represents a mathematical operation
[[email protected] squid]# echo ' expr 7 + 2 '
9
(3) Let means mathematical operations
[[email protected] squid]# let a=7+2
[Email protected] squid]# echo $a
9
(4) (()) Mathematical calculations
[Email protected] squid]# ((b=7+2))
[Email protected] squid]# echo $b
9
4. Looping statements
For loop repeats for the same command in the list
[Email protected] test2]# vim 1.sh
#!/bin/bash
For NUM in {1..3}
Do
Echo $NUM
Done
[Email protected] test2]#./1.sh
1
2
3
5.bash Position Parameters
Position parameter itself: $1,$2,..
Total position parameters: $#
All position parameters: [Email protected],$*
6. Exit status
When the command is complete, return to exit status. Exit status is 0 on success, non-zero when error occurs
The exit status value is stored in the? "In, to see with echo $?" Commands to view
7.test condition judgment
The test command evaluates an expression in a bash script. Returns a 0 state when the expression is true, or a non-0 exit state when the expression is false.
Grammar:
(1) Non-0 or 0-length string operators
[[Email protected] mnt]# [-n Westos] && echo yes | | Echo No
Yes
[[Email protected] mnt]# [-Z "] && echo yes | | Echo No
Yes
(2) string comparison operators
[[Email protected] mnt]# [123 = 123] && echo yes | | Echo No
Yes
[[Email protected] mnt]# [123 =] && echo yes | | Echo No
No
[[Email protected] mnt]# [123! = 123] && echo yes | | Echo No
No
[[Email protected] mnt]# [123! =] && echo yes | | Echo No
Yes
(3) Numeric comparison operators
-eq,-ne,-lt,-le,-GT,-ge
= = < <= > >=
(4) File status operators
Test-{b|c|e|f|d|r|w|x|s| L} file/directory
(5) Binary file operators
-ef determine if the two file has the same node number
-nt,-ot Judging file timestamp new and old
(6) Logical operators
-O satisfies either
-A multiple simultaneous meeting
&& exit status is 0 o'clock execution
|| Exit status non-zero execution
8.if statements
The f command checks the exit value of the command or list after the IF. If the first command evaluates to true/0, then run then
List of commands to be followed until any else. If the first command evaluates to false/nonzero, run the Else and fi
A list of commands between the
9.case statements
Match the contents of the variable with multiple templates, and then decide what to do according to the template that successfully matches
Part of the code.
10.expect statements
(1) Installation expect
Yum Install Expect-y
(2) Script writing
#!/usr/bin/expect # #告诉操作系统用那个shell执行代码
Spawn Command # #给后面shell指令加壳, used to pass interactive instructions
Expect "character" # #问题包含的字符
Send "answer \ r" # #回答问题
Expect EOF # #在输出中搜索文件结束符, if there is no such line, the script exits immediately without getting the correct result
Interact # #执行完成后保持交互状态, hand control over to the console.
$ARGV the parameter array # #接受从bash传递过来的参数.


Linux (11)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.