Thursday, October 7, 2010

Using curl to send/receive data from/to server

curl is a client which sends and receives documents from server without much GUI interaction.

In ATG, we have findclass.jhtml, which will let us know from where the class is refereed from.
for example: http://localhost:7001/dyn/dyn/findclass.jhtml


If you view page source of the findclass.jhtml,
you will see form inside findclass.jhtml has get method which is expecting className.

So by using below command you will get the result
curl -silent -d "className=atg.adapter.gsa.GSARepository" http://localhost:7001/dyn/dyn/findclass.jhtml | grep zip
will give the path from where the class is reffered from.
Explanation:
use man curl for more info
curl is a tool to transfer data from or to a server.
-d : Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button

For example: If you want to set loggingdebug to true of any repository  ex: /atg/userprofiling/ProfileAdapterRepository

The form method will be like below
<form method="POST" action="/dyn/admin/nucleus/atg/userprofiling/ProfileAdapterRepository/">
<input type="hidden" value="loggingDebug" name="propertyName">
<input type="radio" checked="" value="true" name="newValue">true<br>
<input type="radio" value="false" name="newValue">false
<p><input type="submit" value="Change Value" name="change">
</p><p>(Note that values changed here are not written permanently to the properties files)
</p><p>
</p><h1><a name="properties"></a>Properties</h1>
<table border="1">
<tbody><tr><th>Name</th><th>Value</th><th>Type</th></tr>
<tr class="even"><td><a href="/dyn/admin/nucleus/atg/userprofiling/ProfileAdapterRepository/?propertyName=loggingDebug.class">class</a></td><td>Class <a href="/dyn/admin/nucleus/atg/dynamo/docs/apidoc/java/lang/Boolean.html">java.lang.Boolean</a></td><td>java.lang.Class</td></tr>
</tbody></table>
</form>
So
curl -u admin:admin -silent -d "newValue=true&change=Change Value" http://bsdevprem01:7001/dyn/admin/nucleus/atg/userprofiling/ProfileAdapterRepository/?propertyName=loggingDebug > /dev/null
-u is to send username:password for admin UI
-d is to post the required form data
> /dev/null redirecting output to null
In more formal way

onDebug.sh
if [ -n "$1" ]; then
curl -u admin:admin -d "newValue=$4&pchange=Change%20Value" http://$1/dyn/admin/nucleus$2/?propertyName=$3
else
echo "Usage: ./curlexample localhost:7001 /com/att/wireless/recommendation/PopularDevices loggingDebug true"
fi
----------------------------------------------------------------------------------

No comments:

Post a Comment