[Turn]http://www.knktc.com/2011/08/20/linux-shell-expect%e6%89%b9%e9%87%8fscp%e8%84%9a%e6%9c%ac%e5%b7%a5%e5%85%b7/
One of the most recent tasks in preparing a deployment is to send some files, such as installation packages, to a large number of servers. Although there is already a Brother Woo script available: A Python script written by the SSH and SCP features provided by the Paramiko module. But I'm still in the fear of Python (though I've worked m
Sch Help Shell Scripting Encryption Geneva I. Span style= "Word-wrap:break-word; Font-weight:normal; font-size:7pt; Font-family: ' Times New Roman ' ">NBSP;NBSP; introduction SHC (shell script compiler) shell script compiler. by SHC Compiled scripts are unreadable to ordinary users, so if you want your c
Previous section Review In the previous blog post, I focused on the background of Shell scripting, how to create the first shell script in life, and the shell variables. The next step is to introduce shell programming, mainly around she
addition to Shebang, the # occupies the absolute beginning of the content, is the comment line, the interpreter ignores the contents of such a line;3. The explanation ignores all blank lines in the script;4. Lots of commands and keywords (if,else,then,do,while,for, ... )Note: Once the shell script runs in the current shell according to Shebang's instructions, an interpreter (child
Scripting programming languages and compiled languages:
Scripting programming Language: (Bash)
The scripting language is usually interpreted (interpreted), which is read into the program code primarily by the interpreter (interpreter) and is translated into an internal form for execution.
Advantages:
can easily handle objects such as files and directories.
D
Security code: Waves will sometimes, straight hanging cloud sail sea Shell scripting App (iii)Foreword: It is difficult to write all the code in sequential order when it is hard to satisfy the requirements when facing various lists and repeating tasks. Use other program control structures such as loops, branches, and more to make it easier to perform more complex and powerful functions.1. Use a For Loop sta
-5.1.29.jar;. /lib/match.jar Com.test.web.MatchShell script:/usr/java/jdk1.6.0_32/bin/java-xms512m-xmx512m-xx:newratio=3-classpath./match.jar:./ Mysql-connector-java-5.1.29.jar Com.test.web.MatchWhere the bat file differs from the shell script in that the JDK is located on a different path. \jdk1.6.0\bin specifying the JDK path-xms512m-xmx512m-xx:newratio=3 Configuring memory to run the current script-classpath.;. /lib/mysql-connector-java-5.1.29.jar;
\u indicates that the current user name \h represents the machine name \w represents the base name of the current working directory \w represents the full path to the current working directory. $, $, $, $: $ The name of this shell file refers to the first one passed to the shell program The parameter "$" refers to the second parameter, "$" refers to the third parameter $# the number of arguments in the
the default format for shell scripts written in Windows systems is DOS instead of UNIX, resulting in incorrect output results.Look at the format of the shell script and edit the shell script with VI. Then enter ": Set FF?" If the output end is "Fileformat=dos", you need to modify the format of the file// modify file format, open
enter a variable value to the variable name at the keyboardIf you read+ multiple variable names, separate the values of the input variables with a space.More useful Commands read-p "Please input xxxxx:" + variable nameThe scope of the The export variable name can declare a variable as a global variable (this variable can be used in a child shell)be able to export XX = xxx at the time of definitionUse the unset variable name to eliminateOperation of C
specified shell command
V
Start the VI editor with the current file
.
Repeat the previous command
N
Find in file the overflow matches the content of the specified expression
‘
Jumps to the first content that the specified expression matches to
Ctrl+l
Redraw the current scre
Qiniu Seven cow problem solutionGetting started with the Shell scripting languageProblem solving Shell Daily learningCd/go to the root directory PWD current directory structure tab blur find complete command IFCONFG view current network information *? [] wildcard character convenient query star flower * match multiple ls *.tar? Matches a single LS m??? [] LS m* [
results of "mail.jpg tux.jpg".quotation marks (single and double quotation marks) prevent this wildcard extension:
#!/bin/shecho "*.jpg" Echo ' *.jpg '
This will print "*.jpg" two times.Single quotes are more restrictive. It prevents any variable expansion. Double quotes prevent wildcard expansion but allow variable expansion.
#!/bin/shecho $SHELLecho "$SHELL" Echo ' $SHELL '
The result of the operation is
.2) read uses the IFS character to parse the text, and here we specify the IFS as a comma.Cat >> $outfile This includes an output append redirect (>>) and an input append redirect (>> appends the output of the cat command to the file specified by the $outfile variable.The input to the Cat command is not taken from standard input, but is redirected to the data stored in the script.The EOF symbol marks the beginning and end of the data appended to the file.Input file + run + Result:DescriptionSpe
, The interpreter (interpreter) needs to read the source code that we wrote and convert it to the target (object), which is then run by the computer. Because each execution of the program is more than the compilation process, so efficiency has decreased.The advantage of using scripting languages is that they are mostly run at a higher level than the compiled language and can easily handle objects such as files and directories, and the disadvantage is
Direcotry" fiOperation Result:$ sh test.sh13File is an ordinary fileNot Direcotrymay also be unfamiliar with some of the above operators, with a detailed list of operators below.
Operator
Description
-B File
Detects if the file is a block device file, and returns True if it is.
-C file
Detects if the file is a character device file, and returns True if it is
-D File
Detects if the file is a directory, and
used to save the script– Use these variables directly– You cannot assign values directly to these variables $# The number of position variables that have been loaded$* values for all positional variables$? Status value after program exit, 0 indicates normal, other value is abnormal$ (): The output of the command, as a parameterCommon Test OptionsCheck file status-e: Document exists as true-D: Document exists and is directory-True-F: Document exists and is file-true-r: Document exists with Read
by default.The list of REDIRECT commands is as follows:
Command
Description
Command > File
Redirects the output to file.
Command
Redirects the input to file.
Command >> file
Redirects the output to file in an append manner.
n > File
redirect files with file descriptor N to file.
n >> File
Files with file descriptor n are redirected to file in an append manner.
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.