jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "BAZLEY, Sebastian" <>
Subject RE: BeanShell
Date Fri, 02 Jul 2004 13:09:12 GMT
>-----Original Message-----
>From: Jean-Denis Giguere []
>Sent: 02 July 2004 13:52
>To: JMeter Users List
>Subject: BeanShell
>Hi list,
>I would like to use the __BeanShell function but I don't find 
>answers to 
>my questions in the jmeter doc. If someone use this function and can 
>answer my questions, it will be really appreciated.
>1. Which way can we pass the script in argument ? (Ralative path from 
>where we launch jmeter, relative path from jmeter bin, 
>absolute path or 
>you have to write directly the script as argument ?)

The script parameter is just that - a script, not a file containing a

>2.Can we pass arguments to the script ?
>(ex. ${__BeanShell(myscript.bsh foo 13,answer)}

You can use function calls in the script paramater string.

>4. Can we pass the name of the script as a variable ?
>(ex. ${__BeanShell(${myScript},answer)}

See 1. The script does not have a "name". But you can pass a script in a

>3. The doc says that this function return the "result" of the script 
>passed in argument. How do you define the result of the script 
>? (Is it 
>the last variable assignation, the return of the main 
>function, the last 
>print ?)

See the BeanShell documentation for details, but IIRC, it will use the
return value or failing that the last assignment (it may even return the
last value).

>If someone has an exemple and would accept to share it (with the 
>function call and the result), it can help me very much.

${__BeanShell(return "abcd";)} -> abcd

${__BeanShell(return "${__threadNum()}";)} -> same as ${__threadNum()}

${__BeanShell(return Threads.currentThread().getName();)} should return the
current thread name

I think you can probably omit the return statement - try it and see.

Note that the current implementation is not as efficient as it could be -
the script is parsed anew each time, even if it has not been changed.

What do you want to use it for?

>Thank you for your attention,
>Jean-Denis Giguère
>To unsubscribe, e-mail:
>For additional commands, e-mail:


This e-mail and the documents attached are confidential and intended solely
for the addressee; it may also be privileged. If you receive this e-mail in
error, please notify the sender immediately and destroy it. As its integrity
cannot be secured on the Internet, the Atos Origin group liability cannot be
triggered for the message content. Although the sender endeavours to maintain
a computer virus-free network, the sender does not warrant that this
transmission is virus-free and will not be liable for any damages resulting
from any virus transmitted. 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message