O forum atual do agile testers está sendo depreciado, ou seja, não é possível criar ou responder a threads no momento. Por favor utilize o novo fórum https://github.com/AgileTesters/forum/issues

Create xml with shell script

Topic created · 2 Posts · 2164 Visualizações
  • Today I will post a shell script that I am using to test a webservice. If you need a xml to test the performance of the server/webservice with Jmeter or if you just need generate a lot of xmls to make any type of test, this example can be useful.

    In this code you can generate xmls and change some tags as id, date, etc…

     defaultpath="/User/" #Change this for the path where you want the files stay
     echo "What do you want generate ?"
     read element
     echo "How many files ?"
     read filescount
     #Creating the subdirectory for each element and removing the existing folder
     if [ ! -d $element ]
        mkdir "$element"
        rm -r "$element"
        mkdir "$element"
     dateformat=$(date +"%m/%d/%YT%H:%M:%S")
     for (( i=0;i<$filescount;i++ )) do
       exec 3>temp.xml #Creating temporary file
        #HEADER (Common for all xmls)
        echo '&3
        echo ' xmlns:cpi="http://xml.wordpress.co.uk/types" >' >&3
        echo " http://localhost:9999/$element$i" >&3
        echo ' Title' >&3
        echo " $dateformat" >&3
        echo ' ' >&3
        echo ' Rafaela Azevedo' >&3
        echo ' http://wordpress.com/img.png' >&3
        echo ' [email protected]' >&3
        echo " " >&3
        case $element in
        echo ' Content Test' >&3
        echo ' ' >&3
        echo '' >&3
        echo ' http://weather.gov/images/xml_logo.gif' >&3
        echo ' NOAAs National Weather Service' >&3
        echo ' http://weather.gov' >&3
        echo '' >&3
        echo '' >&3
        cp ./temp.xml ${element}/$element-$i.xml #Copying the temporary files
        rm ./temp.xml #Removing the temp files
        echo "Created xml files"

    It is helping me a lot lately , I do not need spend a lot of time doing some complex code or generate these files manually. I hope this helps you too .

    If you have any suggestion or question, write a comment bellow :)

    Thank you guys !

  • @Rafaela-Azevedo Coloquei um markup no seu post, mas se possível, de uma olhada para ver se a indentação está correta :)

    Vlw pela contribuição!