As variáveis não são expandidas entre aspas simples, use aspas duplas:
curl ... "...${var%.*}..."
Eu posso executar comandos cURL individuais usando
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
Mas eu preciso percorrer toda a lista de arquivos shp e, portanto,
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
Mas, diferentemente do sucesso que recebo quando estou adicionando-os individualmente, recebo um erro quando faço um loop,
* 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
Estou fazendo algo errado no loop, já que os cURLs individuais funcionam bem. Como posso corrigir isso?
As variáveis não são expandidas entre aspas simples, use aspas duplas:
curl ... "...${var%.*}..."