Support Questions

Find answers, ask questions, and share your expertise

curl command failing

avatar
Super Collaborator

my rest server is up and running and the following command works

[root@hadoop1 ~]# curl --negotiate -u : 'http://hadoop1:17001/status/cluster'
1 live servers, 0 dead servers, 6.0000 average load
1 live servers
    hadoop5.xxx.com:16020 1530282635984
        requests=0, regions=6
        heapSizeMB=145
        maxHeapSizeMB=2007

but the other curl commands are failing with authentication error . I have a Kerberos ticket acquired from

/etc/security/keytabs/hbase.service.keytab

[root@hadoop1 ~]# curl -H "Accept: text/xml" http://hadoop1:17001/version
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 401 Authentication required</title>
</head>
<body><h2>HTTP ERROR 401</h2>
<p>Problem accessing /version. Reason:
<pre>    Authentication required</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>                                           
<br/>

1 ACCEPTED SOLUTION

avatar
Super Guru

@Sami Ahmad,

You have to use negotiate for all the curl calls

curl --negotiate -u -H "Accept: text/xml" http://hadoop1:17001/version

View solution in original post

10 REPLIES 10

avatar
Super Guru

@Sami Ahmad,

You have to use negotiate for all the curl calls

curl --negotiate -u -H "Accept: text/xml" http://hadoop1:17001/version

avatar
Super Collaborator

ok I will use negotiate ..can you tell why I am not seeing the right formatted output of table names but I see "<" ">" around them ?

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><TableList><table name="UFM"/><table name="WZ"/><table name="state_code"/></TableList>[root@hadoop1 ~]#

avatar
Super Guru

@Sami Ahmad,

This is not an issue. You can use some xml formatter to pretty print it since you are getting proper results.

avatar
Super Collaborator

I am getting the proper results .. the tables are there in the xml list "UFM" "WZ" , how can I make them appear in normal format like ?

UFM

WZ

avatar
Super Guru

@Sami Ahmad,

You need to use some XML parsers to parse the results and get the table names to get the desired output you want.

https://unix.stackexchange.com/questions/83385/parse-xml-to-get-node-value-in-bash-script

avatar
Super Collaborator

77874-capture.jpg

please see above , this is from the hortonworks document , how they are able to get the right output without any xml parsing ?

avatar
Super Collaborator

oh the following syntax worked

[root@hadoop1 ~]# curl --negotiate -i -u : -X GET -H "Accept: text" http://$(hostname):17001/
HTTP/1.1 401 Authentication required
WWW-Authenticate: Negotiate
Set-Cookie: hadoop.auth=; Path=/; HttpOnly
Content-Type: text/html; charset=iso-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 1393
HTTP/1.1 200 OK
Set-Cookie: hadoop.auth="u=hbase&p=hbase/hadoop1.xxx.com@XXX.US&t=kerberos&e=1530331783162&s=Ypuvww45JSzCbQwTbc5ysWmaSfI="; Path=/; HttpOnly
Content-Type: text/plain
Cache-Control: no-cache
Content-Length: 18
UFM
WZ
state_code


avatar
Super Guru

@Sami Ahmad,

To get output in the above format you should not pass the "Accept: text/xml" header. Just try hitting

curl --negotiate -u http://hadoop1:17001

avatar
Super Collaborator

he doesn't like the syntax of this

# curl --negotiate -u http://hadoop1:17001
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information