How to put your bash variable in CURL



  • Hey, everybody, we need to automate the applications for five similar services, make a critical input through the tower, and how to put them in the body of the request, give them a little clipping.

    --data-binary $'------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="sessid"\r\n\r\nc72598fa151fe6ddaae89efe476270bb\r\n------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="Update"\r\n\r\nY\r\n------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="COPY_ID"\r\n\r\n0\r\n------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="ACTIVE"\r\n\r\nY\r\n------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="NAME"\r\n\r\nTEST_NAME\r\n------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="LAST_NAME"\r\n\r\nTEST_FAMILY\r\n------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="SECOND_NAME"\r\n\r\nTEST_PATROM\r\n------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="EMAIL"\r\n\r\nTEST_EMAIL@testmail.ru\r\n------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="LOGIN"\r\n\r\nTest\r\n------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="NEW_PASSWORD"\r\n\r\nTEST_PASS\r\n------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="NEW_PASSWORD_CONFIRM"\r\n\r\nTEST_PASS\r\n------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="LID"\r\n\r\ncp\r\n------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="GROUP_ID_0"\r\n\r\n131\r\n------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="GROUP_ID_FROM_0"\r\n\r\n\r\n------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="GROUP_ID_TO_0"\r\n\r\n\r\n------WebKitFormBoundary358DzhBEThSvxSfb\r\nContent-Disposition: form-data;
    name="GROUP_ID_1"\r\n\r\n130\r\n------WebKitFormBoundary358DzhBE
    

    I want to draw attention.

    name="NAME"\r\n\r\nTEST_NAME\r\n------WebKitFormBoundary358DzhBEThSvxSfb`\r\nContent-Disposition: form-data;
    

    If I point out TEST_NAME, everything works perfectly if I give you the variable $User_Name, with the same meaning, it just doesn't work, it's understandable, because it's a request for a single bowl if you write:

    name="NAME"\r\n\r\n'$User_Name'\r\n------WebKitFormBoundary358DzhBEThSvxSfb`\r\nContent-Disposition: form-data;
    

    Everything that happens after, it cuts off, and it's the the field.

    How do you fix that?



  • within the parameters transmitted to the programme curla special syntax for the line: $'строка'..he is supported in popular shells (e.g., bash and zshbut as far as I know, it's not in the standard. posix

    There's a type of substitution inside the line. \n on the symbols, for example, the line \n converted into a portable line symbol of sixteenth importance 0a)


    I'll show you what happened to you.

    Let us have a line containing \nWhen interpreting it, the shell shall be transformed:

    $ echo $'a\nb\nc'
    a
    b
    c
    

    If you don't use this syntax, there's no change:

    $ echo 'a\nb\nc'
    a\nb\nc
    

    By ripping the line into two parts and putting the symbol instead of, for example, b We'll get:

    $ var=zzz; echo $'a\n'$var'\nc'
    a
    zzz\nc
    

    i.e., second part'\nc'() The changes described have not been made, so that they occur and there, the second part should also be recorded using the same special syntaxis ($'\nc'😞

    $ var=zzz; echo $'a\n'$var$'\nc'
    a
    zzz
    c
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2