I have create a service, a route, an auth, a consumer, a username and a password in the kong admin UI through curl command. Below there is the command that I have used and it's showing in the kong admin UI.
I have installed Kong as docker container with image version is kong/kong-gateway:2.8.1.2-alpine
curl -X POST http://x.x.x.x:8001/services \
--data name=admin-api \
--data host=x.x.x.x \
--data port=8001
curl -X POST http://x.x.x.x:8001/services/admin-api/routes \
--data paths\[\]=/admin-api
curl -X POST http://x.x.x.x:8001/services/admin-api/plugins \
--data "name=basic-auth" \
--data "config.hide_credentials=true"
curl -d "username=first-consumer&custom_id=1" http://x.x.x.x:8001/consumers/
curl -X POST http://x.x.x.x:8001/consumers/first-consumer/basic-auth \
--data "username=first-consumer" \
--data "password=my-password"
curl -s -X GET \
--url http://x.x.x.x:8000/admin-api \
--header 'Authorization: Basic Zmlyc3QtY29uc3VtZXI6bXktcGFzc3dvcmQK'
Below command I get 200 ok response
curl -i -X GET --url http://20.69.125.27:8000 --header "Host: petstore.swagger.io" --header "apikey: apisec"
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Content-Length: 734
Connection: keep-alive
Date: Wed, 10 Aug 2022 11:52:06 GMT
Server: nginx
Last-Modified: Tue, 02 Aug 2022 12:23:11 GMT
Vary: Accept-Encoding
ETag: "62e9172f-2de"
Expires: Thu, 11 Aug 2022 11:52:06 GMT
Cache-Control: max-age=86400
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type
Accept-Ranges: bytes
X-Kong-Upstream-Latency: 322
X-Kong-Proxy-Latency: 52
Via: kong/2.8.1.2-enterprise-edition
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" />
<link rel="stylesheet" type="text/css" href="index.css" />
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
</head>
<body>
<div id="swagger-ui"></div>
<script src="./swagger-ui-bundle.js" charset="UTF-8"> </script>
<script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script src="./swagger-initializer.js" charset="UTF-8"> </script>
</body>
</html>
im getting above output in html but i want in json format
How to get fetch on https://petstore.swagger.io/v2/swagger.json through curl as json file from kong setup ?
Related
I have for example a bunch of HTML pages like this :
<!DOCTYPE html>
<html>
<head><title>Table des matières</title>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8"" />
<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)" />
<meta name="originator" content="TeX4ht (http://www.tug.org/tex4ht/)" />
<!-- 3,html,xhtml,charset="utf-8" -->
<meta name="src" content="content_final.tex" />
<link rel="stylesheet" type="text/css" href="content_final.css" />
<script type="text/javascript" src="./jquery.js">
</script>
<script type="text/javascript">
$(document).ready(function() {
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
}
$('div.caption span.id').each(function() { var result = $(this).text().replace(':','');
result=capitalizeFirstLetter(result);
$(this).text(result);
});
});
</script>
</head><body
>
<!--l. 125--><div class="crosslinks"><p class="noindent">[<a
href="chapter1.html" >next</a>] [tail] [<a
href="/sciences/index.html" >up</a>] </p></div>
<h2 class="likechapterHead"><a
id="x2-1000"></a>Table des matières</h2>
<div class="tableofcontents">
But impossible to convert all french accents in these HTML pages like above the accent in
"Table des matières" with "è" appearing instead of "è".
I tried 2 things :
for i in $(ls *.html); do iconv -f iso-8859-1 -t utf8 $i > $i"_new"; mv -f $i"_new" $i; done
=> the accents are not converted
for i in $(ls *.html); do recode ..html $i; done
=> I have the following errors :
recode: section5.html failed: Invalid input in step `CHAR..ISO-10646-UCS-2'
recode: section6.html failed: Invalid input in step `CHAR..ISO-10646-UCS-2'
recode: section7.html failed: Invalid input in step `CHAR..ISO-10646-UCS-2'
recode: section8.html failed: Invalid input in step `CHAR..ISO-10646-UCS-2'
recode: section9.html failed: Invalid input in step `CHAR..ISO-10646-UCS-2'
recode: table_of_contents.html failed: Invalid input in step `CHAR..ISO-10646-UCS-2'
...
I don't know what to do to convert all these french accents ?
Has anyone got an idea or suggestion to convert all possible french accents ? I would like to use iconv, recode or sed commands.
UPDATE 1: taking a basic example, here is the message I get for a single file :
$ recode ..html table_of_contents.html
recode: table_of_contents.html failed: Invalid input in step `CHAR..ISO-10646-UCS-2'
What's wrong ?
UPDATE 2: here is the output of my original HTML pages :
$file -i index.html
$ index.html: text/x-tex; charset=iso-8859-1
and the head of the index.html :
<!DOCTYPE html>
<html>
<head><title>Table des matières</title>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8"" />
<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)" />
<meta name="originator" content="TeX4ht (http://www.tug.org/tex4ht/)" />
<!-- 3,html,xhtml,charset="utf-8" -->
<meta name="src" content="content_final.tex" />
<link rel="stylesheet" type="text/css" href="content_final.css" />
<script type="text/javascript" src="./jquery.js">
</script>
<script type="text/javascript">
$(document).ready(function() {
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
}
$('div.caption span.id').each(function() { var result = $(this).text().replace(':','');
result=capitalizeFirstLetter(result);
$(this).text(result);
If I apply the command :
$ recode -vfd u8..html index.html
Request: UTF-8..:libiconv:..ISO-10646-UCS-2..HTML_4.0
Shrunk to: UTF-8..ISO-10646-UCS-2..HTML_4.0
Recoding index.html... done
and
<!DOCTYPE html>
<html>
<head><title>Table des matires</title>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8"" />
<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)" />
<meta name="originator" content="TeX4ht (http://www.tug.org/tex4ht/)" />
<!-- 3,html,xhtml,charset="utf-8" -->
<meta name="src" content="content_final.tex" />
<link rel="stylesheet" type="text/css" href="content_final.css" />
<script type="text/javascript" src="./jquery.js">
</script>
<script type="text/javascript">
$(document).ready(function() {
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
}
$('div.caption span.id').each(function() { var result = $(this).text().replace(':','');
result=capitalizeFirstLetter(result);
$(this).text(result);
});
});
</script>
as you can see, the "è" has disappeared.
What can I do ?
Assuming the source file encoding is UTF-8. Following command worked in my environment:
$ recode -vfd u8..html index.html
Output:
$ locale charmap
UTF-8
$ file -i index.html
index.html: text/html; charset=utf-8
$ recode -vfd u8..html index.html
Request: UTF-8..:iconv:..ISO-10646-UCS-2..HTML_4.0
Shrunk to: UTF-8..ISO-10646-UCS-2..HTML_4.0
Recoding index.html... done
You can use the command options to debug the error in this way:
-v Verbose output. Useful to find in which step the error occurred.
-f Forces the completion even if error occurred. You can compare the output file with original to figure out which character/location is giving trouble.
-d For HTML, recode doesn't convert ASCII characters. Avoids conversion of < > " & etc. html characters.
Update If the encoding/charset is iso-8859-1 then you need to use:
$ recode -vfd iso-8859-1..html index.html
Request: ISO-8859-1..ISO-10646-UCS-2..HTML_4.0
Recoding index.html... done
#Or use following.
$ recode -vfd lat1..html index.html
Request: ISO-8859-1..ISO-10646-UCS-2..HTML_4.0
Recoding index.html... done
The ISO-8859-1 has following aliases in recode:
l1
lat1
latin1
Latin-1
819/CR-LF
CP819/CR-LF
CSISOLATIN1
IBM819/CR-LF
ISO8859-1
iso-ir-100
ISO_8859-1
ISO_8859-1:1987
You can use anyone of the above in the command.
html:5 will be expanded as following by default with emmet.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
</html>
I want to customize it as following when to expand html:5 in my vim.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link href="" >
</head>
<body>
</body>
</html>
Here is my try .
vim snippets.json
#to change the line containing doc": as
doc": "html>(head>meta[charset=${charset}]+meta:vp+meta:edge+link[href=\"\"])+body",
Why still no link tag when to expand html:5?
I assume that you are using the emmet-vim plugin.
It stores the complete emmet configuration, including the snippets section, inside
the .vim/autoload/emmet.vim file, which is why it does not see the changes you make to your standalone snippets.json file.
Here is what plugin documentation at vim.org says:
You can customize behavior of expanding with overriding config.
This configuration will be merged at loading plugin.
let g:user_emmet_settings = {
\ 'indentation' : ' ',
\ 'perl' : {
\ 'aliases' : {
\ 'req' : 'require '
\ },
\ 'snippets' : {
\ 'use' : "use strict\nuse warnings\n\n",
\ 'warn' : "warn \"|\";",
\ }
\ }
\}
So, what you have to do, to add <link/> to the html:5 snippet, is add the following to your ~/.vimrc file:
let g:user_emmet_settings = {
\ 'html' : {
\ 'snippets' : {
\ 'html:5': "<!DOCTYPE html>\n"
\ ."<html lang=\"${lang}\">\n"
\ ."<head>\n"
\ ."\t<meta charset=\"${charset}\">\n"
\ ."\t<title></title>\n"
\ ."\t<link href=\"\">"
\ ."</head>\n"
\ ."<body>\n\t${child}|\n</body>\n"
\ ."</html>"
\ }
\ }
\}
now when you restart vim and type html:5 <c-y>, it will produce what you want:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link href="">
</head>
<body>
Alternatively, install the Vim WebAPI plugin, and load your custom snippets.json with it, like this:
~/.vimrc
let g:user_emmet_settings = webapi#json#decode(join(readfile(expand('~/snippets.json')), "\n"))
~/snippets.json
{
"html" : {
"snippets": {
"html:5": "<!DOCTYPE html>\n <html lang=\"${lang}\">\n<head>\n \t<meta charset=\"${charset}\">\n \t<title></title>\n \t<link href=\"\"> </head>\n <body>\n\t${child}|\n</body>\n </html>"
}
}
}
I'm making a script where a major part of it is to login through a system called Feide. I've used Perl and cURL, and I've managed to actually log in and make a session cookie, but due to the fact that cURL doesn't support Javascript, I have to press a button ("Since your browser does not support JavaScript, you must press the button below once to proceed.") to get to the content of the site I want to access. Unfortunately, the form is weird. When I run my script, it simply redirects me back to the same site, and I don't know why. Here's the HTML:
<body onload="document.getElementsByTagName('input')[0].click();">
<noscript>
<p><strong>Note:</strong> Since your browser does not support JavaScript, you must press the button below once to proceed.</p>
</noscript>
<form method="post" action="https://innsida.ntnu.no/c/portal/login">
<!-- Need to add this element and call click method, because calling submit()
on the form causes failed submission if the form has another element with name or id of submit.
See: https://developer.mozilla.org/en/DOM/form.submit#Specification -->
<input type="submit" style="display:none;" />
<input type="hidden" name="SAMLResponse" value="[very long value]" />
<input type="hidden" name="RelayState" value="https://innsida.ntnu.no" />
<noscript>
<input type="submit" value="Submit" />
</noscript>
</form>
</body>
Maybe there's something I'm missing, but I can't seem to submit this form in a proper manner. Here's my script:
use strict;
use warnings;
use WWW::Curl::Easy;
use WWW::Curl::Multi;
use WWW::Curl::Share;
use WWW::Curl::Form;
use DBI;
my $dbh = DBI->connect('DBI:mysql:feide', '[myusername]', '[mypassword]') || die "Could not connect to database: $DBI::errstr";
my $username = $dbh->prepare('SELECT username FROM credentials WHERE id=1');
my $password = $dbh->prepare('SELECT password FROM credentials WHERE id=1');
my $curl = WWW::Curl::Easy-> new;
$curl->setopt(CURLOPT_HEADER, 1);
#Make sure redirects don't fuck me
$curl->setopt(CURLOPT_FOLLOWLOCATION, 1);
#Where cookies are saved
$curl->setopt(CURLOPT_COOKIEJAR, 'cookies.txt');
#Where cookies are read from
$curl->setopt(CURLOPT_COOKIEFILE, 'cookies.txt');
$curl->setopt(CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1");
$curl->setopt(CURLOPT_URL, 'https://idp.feide.no/simplesaml/module.php/feide/login.php?asLen=225&AuthState=_3f669be75024644be95e67ec6845222aefa860db98%3Ahttps%3A%2F%2Fidp.feide.no%2Fsimplesaml%2Fsaml2%2Fidp%2FSSOService.php%3Fspentityid%3Durn%253Amace%253Afeide.no%253Aservices%253Ano.ntnu.innsida%26cookieTime%3D1456232047%26RelayState%3Dhttps%253A%252F%252Finnsida.ntnu.no');
my $response_body;
$curl->setopt(CURLOPT_WRITEDATA,\$response_body);
my $retcode = $curl->perform;
my $checkSession = 0;
my #split;
#check if there is a current session
if($response_body =~ /"AuthState" value="/){
#split = split /"AuthState" value="/, $response_body;
my #authState = split /"/, $split[1];
#make a form for a POST-request
my $curlf = WWW::Curl::Form->new;
$checkSession = 1;
$curlf->formadd("feidename", $username);
$curlf->formadd("password", $password);
$curlf->formadd("asLen", "225");
$curlf->formadd("AuthState", $authState[0]);
$curlf->formadd("org", "ntnu.no");
$curl->setopt(CURLOPT_HTTPPOST, $curlf);
$retcode = $curl->perform;
}
if ($checkSession){
#split = ();
#split = split /"SAMLResponse" value="/, $response_body;
}
else{
my #split = split /"SAMLResponse" value="/, $response_body;
}
my #SAML = split /"/, $split[1];
#Here I try to create a new form, where I add what
#I believe to be the correct values. They don't work,
#and I get redirected back to the "press the button"-website
my $noJS = WWW::Curl::Form->new;
$noJS->formadd("SAMLResponse", $SAML[0]);
$noJS->formadd("RelayState", "https://innsida.ntnu.no");
$curl->setopt(CURLOPT_HTTPPOST, $noJS);
$curl->setopt(CURLOPT_URL, 'https://innsida.ntnu.no/c/portal/login');
$curl->perform;
print $response_body, "\n";
Naturally, I can't put my username and password to Feide here, so you won't be able to try it out for yourselves. Hopefully someone sees a solution regardless.
I'm posting the entire HTML-code (the output of the script) here at the end, in case someone's interested:
HTTP/1.1 302 Found
Date: Wed, 24 Feb 2016 10:35:10 GMT
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1
Pragma: no-cache
Cache-Control: no-cache, no-store
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Location: https://idp.feide.no/simplesaml/saml2/idp/SSOService.php?SAMLRequest=[removed for security purposes]
Content-Length: 0
HTTP/1.1 200 OK
Date: Wed, 24 Feb 2016 10:35:10 GMT
Server: Apache/2.2.24 (Unix)
X-Powered-By: PHP/5.3.26
Content-Length: 7866
Content-Type: text/html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>POST data</title>
</head>
<body onload="document.getElementsByTagName('input')[0].click();">
<noscript>
<p><strong>Note:</strong> Since your browser does not support JavaScript, you must press the button below once to proceed.</p>
</noscript>
<form method="post" action="https://innsida.ntnu.no/c/portal/login">
<!-- Need to add this element and call click method, because calling submit()
on the form causes failed submission if the form has another element with name or id of submit.
See: https://developer.mozilla.org/en/DOM/form.submit#Specification -->
<input type="submit" style="display:none;" />
<input type="hidden" name="SAMLResponse" value="[ridiculously long value]==" />
<input type="hidden" name="RelayState" value="https://innsida.ntnu.no" />
<noscript>
<input type="submit" value="Submit" />
</noscript>
</form>
</body>
</html>
If I left out something, let me know, and I'll do my best to provide it.
EDIT: When I turned off Javascript in my browser and copied as cUrl, I got this:
curl 'https://innsida.ntnu.no/c/portal/login'
-H 'Host: innsida.ntnu.no'
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
-H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'DNT: 1' -H 'Referer: https://idp.feide.no/simplesaml/module.php/feide/login.php?asLen=225&AuthState= [removed]https%253A%252F%252Finnsida.ntnu.no'
-H 'Cookie: COOKIE_SUPPORT=true; GUEST_LANGUAGE_ID=nb_NO; JSESSIONID=[removed].innsidaprod01; LFR_SESSION_STATE_111384=[removed]; LFR_SESSION_STATE_10135=[removed] -H 'Connection: keep-alive'
--data 'SAMLResponse=[long value]&RelayState=https%3A%2F%2Finnsida.ntnu.no'
I suspect that the form is not validating, and you therefore are redirected to the same form. If they don't have any special kind of scripting protection you should be able to create a valid request by going to the Network Tab of Developer Tools on your browser, and select Copy as cURL. This will give you a list of all options being set on a valid request.
This should help you get past the redirect loop.
At the head of my page, i have the following code:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
but i got the following response header:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 1885
Date: Wed, 07 Oct 2015 03:02:50 GMT
And my page shows æ£åœ¨ä¸Žå…¬ä¼—å·å¯¹è¯ instead of Chinese.
Do u know why?
Update:
I just learned something of document encoding(in browser): The simplified priority for determining document encoding (in browser) is: (1) browser setting, (2) byte order mark (browser is able to determine encoding on its own), (3) HTTP header, (4) meta tag, (5) best guess.
I guess charset property of meta tag doesn't effect HTTP header.
then what is confusing for me is what effect HTTP header. And how can i set charset = utf-8 in HTTP header?
============================ attach Codes==========================
Below is code of HEAD in JSP page:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible"content="IE=9; IE=8; IE=7; IE=EDGE" />
<title>微信公众号</title>
<!--讨论区滚动条begin-->
<link rel="stylesheet" type="text/css" href="<%= basePath %>Resource/css/jscrollpane1.css" />
<script src="<%= basePath %>Resource/js/common/jquery-1.8.0.min.js" type="text/javascript"></script>
<!-- the mousewheel plugin -->
<script type="text/javascript" src="<%= basePath %>Resource/js/common/jquery.mousewheel.js"></script>
<!-- the jScrollPane script -->
<script type="text/javascript" src="<%= basePath %>Resource/js/common/jquery.jscrollpane.min.js"></script>
<script type="text/javascript" src="<%= basePath %>Resource/js/common/scroll-startstop.events.jquery.js"></script>
<!--讨论区滚动条end-->
<script type="text/javascript" src="<%= basePath %>Resource/js/front/talk.js"></script>
</head>
Servlet code is simply:
#WebServlet(name = "InitTalkServlet")
public class InitTalkServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request,response);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置编码
request.setCharacterEncoding("UTF-8");
// 页面跳转
request.getRequestDispatcher("/WEB-INF/JSP/FRONT/talk.jsp").forward(request,response);
}
}
I find a resolution:
Open the JSP file with Sublime, File | Save with Encoding | UTF-8 with
BOM.
but i still don't know why it works.
With the prior posts in SO.com I have tried building my script to send email to my Outlook account with the Image inline in the email body. But the html contents are getting displayed in the html rather displaying the image. Please help.
Here is my snippet
{
echo "TO: XXX#YYY.com"
echo "FROM: TEST_IMAGE#YYY.com>"
echo "SUBJECT: Embed image test"
echo "MIME-Version: 1.0"
echo "Content-Type: multipart/related;boundary="--XYZ""
echo "--XYZ"
echo "Content-Type: text/html; charset=ISO-8859-15"
echo "Content-Transfer-Encoding: 7bit"
echo "<html>"
echo "<head>"
echo "<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">"
echo "</head>"
echo "<body bgcolor="#ffffff" text="#000000">"
echo "<img src="cid:part1.06090408.01060107" alt="">"
echo "</body>"
echo "</html>"
echo "--XYZ"
echo "Content-Type: image/jpeg;name="sathy.jpg""
echo "Content-Transfer-Encoding: base64"
echo "Content-ID: <part1.06090408.01060107>"
echo "Content-Disposition: inline; filename="sathy.jpg""
echo $(base64 sathy.jpg)
echo "' />"
echo "--XYZ--"
}| /usr/lib/sendmail -t
Email I received contains the below rather displaying the image,
--XYZ
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit
<html>
<head>
<meta http-equiv=content-type content=text/html
</head>
<body bgcolor=#ffffff text=#000000>
<img src=cid:part1.06090408.01060107 alt=>
</body>
</html>
--XYZ
Content-Type: image/jpeg;name=sathy.jpg
Content-Transfer-Encoding: base64
Content-ID: <part1.06090408.01060107>
Content-Disposition: inline; filename=sathy.jpg
/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAAoAAD/4QNxaHR0cDov
....base64 values.....
/>
--XYZ--
----XYZ--
Can you please assist me in what am i missing
The way you use echo to print the message headers it eats all double quotes - you need to escape them with a backslash (\") to make it work.
Also, your boundary is wrong. If you define boundary=--XYZ, then each message part needs to start with ----XYZ (you need to add two dashes), otherwise your boundary should be only XYZ. And the headers of the mime parts must be separated from the bodies by an empty line.
If you really need to generate a mail from a shell script, then my advise would be to get rid of all the echo and use a heredoc instead:
sendmail -t <<EOT
TO: XXX#YYY.com
FROM: <TEST_IMAGE#YYY.com>
SUBJECT: Embed image test
MIME-Version: 1.0
Content-Type: multipart/related;boundary="XYZ"
--XYZ
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
</head>
<body bgcolor="#ffffff" text="#000000">
<img src="cid:part1.06090408.01060107" alt="">
</body>
</html>
--XYZ
Content-Type: image/jpeg;name="sathy.jpg"
Content-Transfer-Encoding: base64
Content-ID: <part1.06090408.01060107>
Content-Disposition: inline; filename="sathy.jpg"
$(base64 sathy.jpg)
--XYZ--
EOT