You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by amelaao <am...@gmail.com> on 2006/04/27 23:33:14 UTC

_BeanShell

I want to get the value of current directory into a variable and use it to
create a new path. I'm using BeanShell for this, having my user parameter
workingDir defined as ${__BeanShell(pwd(),)}, thinking that I can use it
later as ${workingDir}. My first test was just to display ${workingDir}
using JavaRequest Sampler before even going further. I downloaded
bshXX.jarin jmeter/lib. However my JavaRequest doesn't print anything
in its
Listener, except for  text "JavaRequest" which is usually not a good sign.

Any ideas?
--
Thanks,
Amela

Re: _BeanShell

Posted by sebb <se...@gmail.com>.
On 28/04/06, amelaao <am...@gmail.com> wrote:
> Well, it didn't do what I wanted it to. If I comment out user.dir in
> properties file, then user.dir is "C:\Program Files\jakarta-jmeter-2.1.1\bin".

Yes, because JMeter currently starts in the bin directory.

[Probably user.dir should not be set in jmeter.properties ...]

> It worked for me before because user.,dir was set to the directory where my
> test scripts are, but in production we are not going to have this property
> set on our servers, because we are going to have many directories
> with different scripts. These scripts are executed from Ant, but also
> manually on tester's local machines. If it was run only from Ant I could
> have this easily taken care of, but since the same script testers will
> download and execute on their machines I have to figure out different way of
> solving this. I probably need to rephrase the question - I need the
> directory of the current test script that is being run.

I've updated the JMeter Windows scripts (.bat and .cmd) in the current
2.1 branch to allow JMeter to be run from anywhere, not just the bin
directory.
[Sorry, this does not yet apply to the jmeter server script]

If you drop a jmx file on jmeter-n.cmd, it will now change the default
directory to the same as that containing the JMX file.

So if you always put the data files in the same place relative to the
JMX files, there should be no need to know the current directory.

Or is there something else you need the current location for?

You could always create your own script file to create a property containg %CD%
[I assume you are running Win2K, not Win9x or ME]

S.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: _BeanShell

Posted by amelaao <am...@gmail.com>.
Well, it didn't do what I wanted it to. If I comment out user.dir in
properties file, then user.dir is "C:\Program Files\jakarta-jmeter-2.1.1\bin".
It worked for me before because user.,dir was set to the directory where my
test scripts are, but in production we are not going to have this property
set on our servers, because we are going to have many directories
with different scripts. These scripts are executed from Ant, but also
manually on tester's local machines. If it was run only from Ant I could
have this easily taken care of, but since the same script testers will
download and execute on their machines I have to figure out different way of
solving this. I probably need to rephrase the question - I need the
directory of the current test script that is being run.

Amela


On 4/28/06, sebb <se...@gmail.com> wrote:
>
> user.dir is set during startup on each host
>
> Try it and see.
>
> On 28/04/06, amelaao <am...@gmail.com> wrote:
> > I realized property user.dir is a solution for my local machine. However
> I
> > can't have this dependency since our scripts are deployed on different
> > machines and used for different releases, plus I don't have the control
> of
> > jmeter.properties file.So my solution needs to read the current
> directory
> > and then use it to calculate the path to some other file. It may be a
> bit
> > confusing, but the bottom line is that I have to use a different way of
> > finding current directory.
> >
> > Thanks,
> > Amela
> >
> >
> > On 4/27/06, sebb <se...@gmail.com> wrote:
> > >
> > > On 28/04/06, amelaao <am...@gmail.com> wrote:
> > > > Sebb,
> > > > Thanks. ${__P(user.dir)} did do the trick without changing anything
> > > else.
> > > > Why do you think _BeanShell didn't work. There were no errors in the
> log
> > > > file, amd at the same place in the Listener after JaveRequest
> Sampler,
> > > where
> > > > it now prints the current dir, there was "JavaRequest".
> > >
> > > Because pwd() _prints_ the current directory - it returns nothing -
> > > output goes to standard output, i.e. the console window.
> > >
> > >
> > > > Amela
> > > >
> > > >
> > > > On 4/27/06, sebb <se...@gmail.com> wrote:
> > > > >
> > > > > On 27/04/06, amelaao <am...@gmail.com> wrote:
> > > > > > I want to get the value of current directory into a variable and
> use
> > > it
> > > > > to
> > > > >
> > > > > ${__P(user.dir)}
> > > > >
> > > > > might work for you.
> > > > >
> > > > > > create a new path. I'm using BeanShell for this, having my user
> > > > > parameter
> > > > > > workingDir defined as ${__BeanShell(pwd(),)}, thinking that I
> can
> > > use it
> > > > > > later as ${workingDir}. My first test was just to display
> > > ${workingDir}
> > > > > > using JavaRequest Sampler before even going further. I
> downloaded
> > > > > > bshXX.jarin jmeter/lib. However my JavaRequest doesn't print
> > > anything
> > > > > > in its
> > > > > > Listener, except for  text "JavaRequest" which is usually not a
> good
> > > > > sign.
> > > > >
> > > > > Which Listener?
> > > > > Where did you put ${workingDir} in the JavaRequest Sampler?
> > > > >
> > > > > > Any ideas?
> > > > >
> > > > > Have you checked in jmeter.log for any error messages?
> > > > >
> > > > > > Thanks,
> > > > > > Amela
> > > > > >
> > > > > >
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > > > > For additional commands, e-mail:
> jmeter-user-help@jakarta.apache.org
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Regards,
> > > > Amela
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> > >
> > >
> >
> >
> > --
> > Regards,
> > Amela
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>


--
Regards,
Amela

Re: _BeanShell

Posted by sebb <se...@gmail.com>.
user.dir is set during startup on each host

Try it and see.

On 28/04/06, amelaao <am...@gmail.com> wrote:
> I realized property user.dir is a solution for my local machine. However I
> can't have this dependency since our scripts are deployed on different
> machines and used for different releases, plus I don't have the control of
> jmeter.properties file.So my solution needs to read the current directory
> and then use it to calculate the path to some other file. It may be a bit
> confusing, but the bottom line is that I have to use a different way of
> finding current directory.
>
> Thanks,
> Amela
>
>
> On 4/27/06, sebb <se...@gmail.com> wrote:
> >
> > On 28/04/06, amelaao <am...@gmail.com> wrote:
> > > Sebb,
> > > Thanks. ${__P(user.dir)} did do the trick without changing anything
> > else.
> > > Why do you think _BeanShell didn't work. There were no errors in the log
> > > file, amd at the same place in the Listener after JaveRequest Sampler,
> > where
> > > it now prints the current dir, there was "JavaRequest".
> >
> > Because pwd() _prints_ the current directory - it returns nothing -
> > output goes to standard output, i.e. the console window.
> >
> >
> > > Amela
> > >
> > >
> > > On 4/27/06, sebb <se...@gmail.com> wrote:
> > > >
> > > > On 27/04/06, amelaao <am...@gmail.com> wrote:
> > > > > I want to get the value of current directory into a variable and use
> > it
> > > > to
> > > >
> > > > ${__P(user.dir)}
> > > >
> > > > might work for you.
> > > >
> > > > > create a new path. I'm using BeanShell for this, having my user
> > > > parameter
> > > > > workingDir defined as ${__BeanShell(pwd(),)}, thinking that I can
> > use it
> > > > > later as ${workingDir}. My first test was just to display
> > ${workingDir}
> > > > > using JavaRequest Sampler before even going further. I downloaded
> > > > > bshXX.jarin jmeter/lib. However my JavaRequest doesn't print
> > anything
> > > > > in its
> > > > > Listener, except for  text "JavaRequest" which is usually not a good
> > > > sign.
> > > >
> > > > Which Listener?
> > > > Where did you put ${workingDir} in the JavaRequest Sampler?
> > > >
> > > > > Any ideas?
> > > >
> > > > Have you checked in jmeter.log for any error messages?
> > > >
> > > > > Thanks,
> > > > > Amela
> > > > >
> > > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> > > >
> > > >
> > >
> > >
> > > --
> > > Regards,
> > > Amela
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
> >
>
>
> --
> Regards,
> Amela
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: _BeanShell

Posted by amelaao <am...@gmail.com>.
I realized property user.dir is a solution for my local machine. However I
can't have this dependency since our scripts are deployed on different
machines and used for different releases, plus I don't have the control of
jmeter.properties file.So my solution needs to read the current directory
and then use it to calculate the path to some other file. It may be a bit
confusing, but the bottom line is that I have to use a different way of
finding current directory.

Thanks,
Amela


On 4/27/06, sebb <se...@gmail.com> wrote:
>
> On 28/04/06, amelaao <am...@gmail.com> wrote:
> > Sebb,
> > Thanks. ${__P(user.dir)} did do the trick without changing anything
> else.
> > Why do you think _BeanShell didn't work. There were no errors in the log
> > file, amd at the same place in the Listener after JaveRequest Sampler,
> where
> > it now prints the current dir, there was "JavaRequest".
>
> Because pwd() _prints_ the current directory - it returns nothing -
> output goes to standard output, i.e. the console window.
>
>
> > Amela
> >
> >
> > On 4/27/06, sebb <se...@gmail.com> wrote:
> > >
> > > On 27/04/06, amelaao <am...@gmail.com> wrote:
> > > > I want to get the value of current directory into a variable and use
> it
> > > to
> > >
> > > ${__P(user.dir)}
> > >
> > > might work for you.
> > >
> > > > create a new path. I'm using BeanShell for this, having my user
> > > parameter
> > > > workingDir defined as ${__BeanShell(pwd(),)}, thinking that I can
> use it
> > > > later as ${workingDir}. My first test was just to display
> ${workingDir}
> > > > using JavaRequest Sampler before even going further. I downloaded
> > > > bshXX.jarin jmeter/lib. However my JavaRequest doesn't print
> anything
> > > > in its
> > > > Listener, except for  text "JavaRequest" which is usually not a good
> > > sign.
> > >
> > > Which Listener?
> > > Where did you put ${workingDir} in the JavaRequest Sampler?
> > >
> > > > Any ideas?
> > >
> > > Have you checked in jmeter.log for any error messages?
> > >
> > > > Thanks,
> > > > Amela
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> > >
> > >
> >
> >
> > --
> > Regards,
> > Amela
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>


--
Regards,
Amela

Re: _BeanShell

Posted by sebb <se...@gmail.com>.
On 28/04/06, amelaao <am...@gmail.com> wrote:
> Sebb,
> Thanks. ${__P(user.dir)} did do the trick without changing anything else.
> Why do you think _BeanShell didn't work. There were no errors in the log
> file, amd at the same place in the Listener after JaveRequest Sampler, where
> it now prints the current dir, there was "JavaRequest".

Because pwd() _prints_ the current directory - it returns nothing -
output goes to standard output, i.e. the console window.


> Amela
>
>
> On 4/27/06, sebb <se...@gmail.com> wrote:
> >
> > On 27/04/06, amelaao <am...@gmail.com> wrote:
> > > I want to get the value of current directory into a variable and use it
> > to
> >
> > ${__P(user.dir)}
> >
> > might work for you.
> >
> > > create a new path. I'm using BeanShell for this, having my user
> > parameter
> > > workingDir defined as ${__BeanShell(pwd(),)}, thinking that I can use it
> > > later as ${workingDir}. My first test was just to display ${workingDir}
> > > using JavaRequest Sampler before even going further. I downloaded
> > > bshXX.jarin jmeter/lib. However my JavaRequest doesn't print anything
> > > in its
> > > Listener, except for  text "JavaRequest" which is usually not a good
> > sign.
> >
> > Which Listener?
> > Where did you put ${workingDir} in the JavaRequest Sampler?
> >
> > > Any ideas?
> >
> > Have you checked in jmeter.log for any error messages?
> >
> > > Thanks,
> > > Amela
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
> >
>
>
> --
> Regards,
> Amela
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: _BeanShell

Posted by amelaao <am...@gmail.com>.
Sebb,
Thanks. ${__P(user.dir)} did do the trick without changing anything else.
Why do you think _BeanShell didn't work. There were no errors in the log
file, amd at the same place in the Listener after JaveRequest Sampler, where
it now prints the current dir, there was "JavaRequest".

Amela


On 4/27/06, sebb <se...@gmail.com> wrote:
>
> On 27/04/06, amelaao <am...@gmail.com> wrote:
> > I want to get the value of current directory into a variable and use it
> to
>
> ${__P(user.dir)}
>
> might work for you.
>
> > create a new path. I'm using BeanShell for this, having my user
> parameter
> > workingDir defined as ${__BeanShell(pwd(),)}, thinking that I can use it
> > later as ${workingDir}. My first test was just to display ${workingDir}
> > using JavaRequest Sampler before even going further. I downloaded
> > bshXX.jarin jmeter/lib. However my JavaRequest doesn't print anything
> > in its
> > Listener, except for  text "JavaRequest" which is usually not a good
> sign.
>
> Which Listener?
> Where did you put ${workingDir} in the JavaRequest Sampler?
>
> > Any ideas?
>
> Have you checked in jmeter.log for any error messages?
>
> > Thanks,
> > Amela
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>


--
Regards,
Amela

Re: _BeanShell

Posted by sebb <se...@gmail.com>.
On 27/04/06, amelaao <am...@gmail.com> wrote:
> I want to get the value of current directory into a variable and use it to

${__P(user.dir)}

might work for you.

> create a new path. I'm using BeanShell for this, having my user parameter
> workingDir defined as ${__BeanShell(pwd(),)}, thinking that I can use it
> later as ${workingDir}. My first test was just to display ${workingDir}
> using JavaRequest Sampler before even going further. I downloaded
> bshXX.jarin jmeter/lib. However my JavaRequest doesn't print anything
> in its
> Listener, except for  text "JavaRequest" which is usually not a good sign.

Which Listener?
Where did you put ${workingDir} in the JavaRequest Sampler?

> Any ideas?

Have you checked in jmeter.log for any error messages?

> Thanks,
> Amela
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org