You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by govardhan nalluri <go...@gmail.com> on 2016/09/23 12:55:38 UTC

Re: How to grep just one string from Response Data and save into .csv file

Hi Sushma,

Please add bean shell code in the BeanShell PostProcessor you can get the
regular expression value to text file. Could you please find the below code


   String V_BatchSeqNumber_Bsh;

    V_BatchSeqNumber_Bsh=vars.get("V_Param_Corr");// after doing in regular
expression and saving to varibale name as in the name V_param_corr
    vars.put("V_nextBatchSeqNumber_JM",V_BatchSeqNumber_Bsh);

    FileOutputStream out = new
FileOutputStream("d:\\results1_BtachSummary.txt", true); // Path very you
want to save
    String newline = System.getProperty("line.separator");
    Set variables = vars.entrySet();

    for (Map.Entry entry : variables) {
        if (entry.getKey().startsWith("V_nextBatchSeqNumber_JM")) {
            out.write(entry.getValue().toString().getBytes("UTF-8"));
            out.write(newline.getBytes("UTF-8"));
            out.flush();
        }
    }

    out.close();

Thanks
Govardhan

On Fri, Oct 2, 2015 at 1:11 AM, Deepak Shetty <sh...@gmail.com> wrote:

> Hi
> no additional libraries are needed. If you are seeing the extra columns ,
> Jmeter is setup correctly , so the problem is in whatever you have
> extracted or in the way you are interpreting results. Note that variables
> are case sensitive so ensure you check those things
>
> Suppose your test is
> Thread Group
> +Sampler1
> +Sampler2
> ++Regex extractor  variable1
> +Listener
> Then you should get 2 rows - One for sampler1 which has null (variable
> doesnt have a value yet) and one for Sampler2 which *should* have the value
> for variable1
>
>
> On Thu, Oct 1, 2015 at 12:02 PM, Sushma Kattinti <
> Sushma.Kattinti@vonagebusiness.com> wrote:
>
> > Hi Deepak,
> >
> > I added the sample_variable in the Jmeter/user.properties.
> >
> > I see the the expression in my Debuger Sampler but in my .cvs file I see
> > “null”
> >
> > You think I am missing any libraries?
> >
> > I am using the Apache Jmeter Version 2.11 r1554548 and the latest and I
> > got the latest http://jmeter-plugins.org/downloads/all/ plugins (Extras
> > with Libs Set)
> >
> > Thanks,
> > Sushma
> >
> >
> >
> > On 10/1/15, 2:52 PM, "Deepak Shetty" <sh...@gmail.com> wrote:
> >
> > >Hi
> > >The variable name that you have used in your extractor (reference name
> in
> > >Regular expression extractor assuming you are getting a single value and
> > >not a list)
> > >Then you'd have something like this in jmeter.properties (or
> > >user.properties)
> > >
> > >sample_variables=variableName1,variableName2
> > >
> > >Docs at
> > >http://jmeter.apache.org/usermanual/listeners.html#sample_variables
> > >
> > >On Thu, Oct 1, 2015 at 11:44 AM, Sushma Kattinti <
> > >Sushma.Kattinti@vonagebusiness.com> wrote:
> > >
> > >>
> > >> I am running this via Jmeter GUI itself for now. Once it works as
> > >> intended, I will push this .jmx file and run it via Blazemeter.
> > >>
> > >> But for now what sample_variable I should be adding in
> > >> jmeter/user.properties.
> > >>
> > >> I am a newbie and trying to explore, apologies if I raise any silly
> > >> questions.
> > >>
> > >> Thanks,
> > >> Sushma
> > >>
> > >>
> > >>
> > >> On 10/1/15, 2:34 PM, "Deepak Shetty" <sh...@gmail.com> wrote:
> > >>
> > >> >Hi
> > >> >
> > >> >Dont use a Save responses to file - Use a different listener like
> > >> >
> > >>
> > >>
> > http://jmeter.apache.org/usermanual/component_
> reference.html#Simple_Data_
> > >>W
> > >> >riter
> > >> >Or if you are running from command line then the -l flag.
> > >> >Scope the listener appropriately (either just as child of the request
> > >>or
> > >> >whatever)
> > >> >
> > >> >Did you add the variable names to sample_variables in jmeter/user
> > >> >.properties?
> > >> >
> > >> >regards
> > >> >deepak
> > >> >
> > >> >On Thu, Oct 1, 2015 at 8:36 AM, Sushma Kattinti <
> > >> >Sushma.Kattinti@vonagebusiness.com> wrote:
> > >> >
> > >> >> Hello Deepak,
> > >> >>
> > >> >> After the POST command I used the Regular Expression Extractor and
> > >>added
> > >> >> my regex expression. I made sure that it is capturing by using a
> > >>Debug
> > >> >> Sampler. I added Save Responses to a file and gave the path for the
> > >>.cvs
> > >> >> file to save the results but I am not able to save just the
> > >>expression I
> > >> >> am looking for. I get the whole response in a file.
> > >> >>
> > >> >> Please let me know if I you need further information and I can
> > >>provide
> > >> >>and
> > >> >> tweak it.
> > >> >>
> > >> >> Thanks for all your help
> > >> >>
> > >> >> Thanks,
> > >> >> Sushma
> > >> >>
> > >> >>
> > >> >>
> > >> >> On 9/29/15, 12:44 PM, "Deepak Shetty" <sh...@gmail.com> wrote:
> > >> >>
> > >> >> >Hi
> > >> >> >a. First you need to extract the value using a post processor -
> This
> > >> >>seems
> > >> >> >to be what you have done with regex post processor. This needs to
> > >>be in
> > >> >> >scope of the sampler that is returning the response - usually it
> is
> > >> >> >created
> > >> >> >as a child of the sampler.
> > >> >> >b. Next you need to verify that your post processor is actually
> > >> >>working -
> > >> >> >So add a debug sampler + view results tree listener after the
> > >>request
> > >> >>that
> > >> >> >you are operating on and you should be able to see whether the
> > >>value is
> > >> >> >being extracted correctly or not
> > >> >> >c. If step  b is printing your variable correctly then the
> simplest
> > >> >>way to
> > >> >> >write variables to file is using
> > >> >> >http://jmeter.apache.org/usermanual/listeners.html#
> sample_variables
> > >>-
> > >> >>so
> > >> >> >you would simply define your variable names in the properties file
> > >>and
> > >> >> >then
> > >> >> >Jmeter would record the value of the variables against every
> > >>response-
> > >> >>If
> > >> >> >you have more complicated needs then roll out your own using any
> of
> > >>the
> > >> >> >listeners that allow you to write your own code. - Note that your
> > >>code
> > >> >> >should be thread safe.
> > >> >> >
> > >> >> >regards
> > >> >> >deepak
> > >> >> >
> > >> >> >
> > >> >> >
> > >> >> >On Tue, Sep 29, 2015 at 8:15 AM, Sushma Kattinti <
> > >> >> >Sushma.Kattinti@vonagebusiness.com> wrote:
> > >> >> >
> > >> >> >> Hello,
> > >> >> >>
> > >> >> >> I am executing GET method and saving output in a csv file. I
> would
> > >> >>like
> > >> >> >>to
> > >> >> >> get just one string from the Response data and put it in a file.
> > >>Any
> > >> >> >>help
> > >> >> >> would be great. I used Regular Expression Extractor and
> BeanShell
> > >> >> >> PostProcessor but I do not see any data coming into file. Each
> > >>column
> > >> >> >>says
> > >> >> >> ³null² instead of the string I am looking for from Response Data
> > >> >> >>
> > >> >> >> Thanks,
> > >> >> >> Sushma
> > >> >> >>
> > >> >> >>
> > >> >> >>
> > >>---------------------------------------------------------------------
> > >> >> >> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > >> >> >> For additional commands, e-mail: user-help@jmeter.apache.org
> > >> >> >>
> > >> >> >>
> > >> >>
> > >> >>
> > >> >> ------------------------------------------------------------
> ---------
> > >> >> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > >> >> For additional commands, e-mail: user-help@jmeter.apache.org
> > >> >>
> > >>
> > >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > For additional commands, e-mail: user-help@jmeter.apache.org
> >
>