The Shell Curl download file

Source: Internet
Author: User

Objective

???? Recently busy turnover of work, there are days without study, lazy ah!

Body

  1. 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

  2. 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

  3. 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"?

  4. Knowledge Point Grooming
    1. 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

    1. 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

    2. 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 '

    1. 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

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.