Objective
???? Recently busy turnover of work, there are days without study, lazy ah!
Body
- Demand
For example, one day we made a software.
Sometimes our software needs to be automatically based on the Internet to get the current version to be updated. Download some necessary files if "online" needs to be updated
- Shell implementations
Local_ver= ' cat version '
Remote_ver= ' Curl Http://[email protected]@@..com/test/conf.txt-s | Sed-n ' 2p ' #-S silent mode, no details displayed
#echo $REMOTE _ver
If [$LOCAL _ver-lt $REMOTE _ver]
Then
# echo "Begin Update"
Get_update= ' curl-d "password=123" Http://[email protected]@@.com/test/update.php-s ' #-d post submission
wget $GET _update
echo "2" >version
Fi
- thinking comb
First judge the local version file, read.
Use curl to access the remote Conf.txt, then take the second line
local and remote versions are compared, If the version is small;
1) simulates the post access update.php and obtains the address to be downloaded
2) using wget download
P style= "text-align:justify"?
- Knowledge Point Grooming
- Curl "command-line Browser" File Transfer tool
Curl http://www.baidu.com
All of the above are accessed directly from the Web page by means of get.
Actually, curl is a great place to simulate the submission.
Curl-d "Write the Post parameters here" write the URL here
- Number comparison
-GT is greater than the meaning of large than
-LT is smaller than less than
-eq is equal to equal
-ne is not equal to not equal
-ge is greater than or equal to large equal
-le is less than equals? Less equal
- Curl Silent mode
Curl URL
will display normally
?
???????? Assigning a value to you the variable will display statistics
???????? result= ' Curl URL '
???????? The echo $result will show statistics
????????????
???????? Silent mode: Do not display statistics
???????? result= ' Curl URL-s '
- Curl URLs need to wait for the site to be appropriate
So with statement 1 | Statement 2
???????????? Represents only the result of statement 1 execution, as a parameter of statement 2
???????????? Then it's OK to read it with SED.
?
End
The Shell Curl download file