Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am able to execute individual cURL commands using,

curl -u user:password -v -XPOST -H 'Content-type: text/xml' -d '<featureType><name>quadrella_indica</name></featureType>' http://localhost:8080/geoserver/rest/workspaces/opengeo/datastores/species/featuretypes

But I need to loop through the entire list of shp file and so,

for f in *.shp
   do 
   a=${f,,};
   curl -u user:password -v -XPOST -H 'Content-type: text/xml' -d    '<featureType><name>${a%.*}</name></featureType>' http://localhost:8080/geoserver/rest/workspaces/opengeo/datastores/species/featuretypes 
done

But unlike the success that I receive when I am adding them individually, I receive an error when I loop through,

* About to connect() to localhost port 8080 (#0)
*   Trying ::1... connected
* Server auth using Basic with user 'admin'
> POST /geoserver/rest/workspaces/opengeo/datastores/species/featuretypes HTTP/1.1
> Authorization: Basic YWRtaW46Z2Vvc2VydmVy
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: localhost:8080
> Accept: */*
> Content-type: text/xml
> Content-Length: 47
> 
* upload completely sent off: 47out of 47 bytes
< HTTP/1.1 400 Bad Request
< Server: Apache-Coyote/1.1
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Date: Sun, 25 Nov 2012 18:19:31 GMT
< Connection: close
< 
* Closing connection #0
Trying to create new feature type inside the store, but no attributes were specified

I am doing something wrong in the looping as the individual cURLs work just fine. How can I correct it?

share|improve this question

1 Answer 1

Variables are not expanded inside single quotes, use double quotes instead:

curl ... "...${var%.*}..."
share|improve this answer
    
So I executed this command, for f in *.shp; do curl -u user:password -v -XPOST -H 'Content-type: text/xml' -d "<featureType><name>${f%.*}_poly</name></featureType>" http://localhost:8080/geoserver/rest/workspaces/opengeo/datastores/species/featu‌​retypes; done but the output is still the same –  Sam007 Nov 26 '12 at 22:38
    
Try to add --trace-ascii - to see the body of the requests. –  Stéphane Chazelas Nov 26 '12 at 22:45
    
not sure where to add it?? i m still a newbie –  Sam007 Nov 27 '12 at 2:53
    
You can put it in place of the -v switch for instance. –  Stéphane Chazelas Nov 27 '12 at 16:07
    
-v is already present –  Sam007 Nov 27 '12 at 18:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.