Cannot run my JMeter webdriver sampler script via command prompt - javascript

When I try to run my JMeter WebDriver sampler script via command prompt, the error below shows up. Is there any solution for this?
F:\apache-jmeter-3.2\bin\TestScriptRecorder.jmx is not a valid Win32 application.

It seems you are trying to execute .jmx file directly, it won't work this way, you need to launch jmeter.bat file and pass the .jmx file via -t command-line argument like:
F:\apache-jmeter-3.2\bin\jmeter.bat -n -t F:\apache-jmeter-3.2\bin\TestScriptRecorder.jmx -l result.jtl
or
java -jar F:\apache-jmeter-3.2\bin\ApacheJMeter.jar -n -t F:\apache-jmeter-3.2\bin\ -l result.jtl
References:
Non-GUI Mode (Command Line mode)
Full list of command-line options
How Do I Run JMeter in Non-GUI Mode?

If you want run your Jmx through command line follow the below steps.
Open command prompt
go to the path of where your jmeter.bat or jmete.sh file is placed(ex: C:\Users\ABC\apache-jmeter-3.3\bin)
Write the command as below
For Windows: jmeter -n -t C:\your_testScript_path\yourscript.jmx
For ubuntu/linux: ./jmeter.sh -n -t C:\your_testScript_path\yourscript.jmx
you can aslo pass any values to the jmx files using command line using command line paremeters like -JUsers=10 where in it should be defined in jmx like ${__P(Users,1)}

Related

^ Character in Node Script Arguments

I have a node script that is receiving the following argument: ^PPP.
I am calling the script as following: npm run scriptName ^PPP.
However inside the script if I do a console.log(process.argv), the output shows my argument as PPP.
I tried escaping the character as npm run scriptName \^PPP and npm run scriptName "^PPP" but to no avail.
Please help how can I receive the original string from the arguments.
PowerShell to run command and v10.16.2 node version
It depends on your terminal.
I made a simple script called args.js with
console.log(process.argv);
Using git bash on windows or WSL (Ubuntu), calling
$node args.js ^PPPP
Outputs
[ 'node/path',
'path/to/args.js',
'^PPPP' ]
Using windows cmd terminal, calling
>node args.js ^PPPP
Outputs
[ 'C:\Program Files\nodejs\node.exe',
'C:\workspace\tests\args.js',
'PPPP' ]
and calling
>node args.js ^^PPPP
Outputs
[ 'C:\Program Files\nodejs\node.exe',
'C:\workspace\tests\args.js',
'^PPPP' ]
So if you are using Windows's terminal, you need to double the ^ character (What does the single circumflex in the windows cmd shell mean: More?). On other terminals, it seems to work fine.
Edit: To add arguments to your node script from npm run, you need to separate them with -- like so:
>npm run scriptName -- ^^PPP

How to run node.js application from script?

I am trying to run my node.js application from a script I have written:
echo "Starting node application"
sudo node /home/pi/PPBot/bot.js
exit 0
I run the script like this: sudo /etc/init.d/botscript
The output when running the script is:
Start node application
sudo: node: command not found
I have also tried replacing node by /home/pi/.nvm/versions/node/v.8.11.3/bin/node but this resulted in the same output.
I have already installed NodeJS through NVM. Simply using the command node bot.js works from the command line. However as can be seen above it does not work through the script.
if you want to run a simple node js file then use the command
-> node filename
ex.: node server.js
if you want to run a node js file with nodemon then use the command
-> nodemon filename
ex.: nodemon server.js

DroidEdit Termux integration

DroidEdit allows you to run commands if you have sl4a installed and the am command works wonderfully... I was wondering if there is a way to use am to launch an app with params .. specifically I want a command that will tell termux to run a command on a file that I specificy ... so far I found this snippet that launches the termux app .. now how do I get it to run node or webpack from npm as well?
am start --user 0 -n com.termux/com.termux.app.TermuxActivity

Running a bash script before startup in an NGINX docker container

I'm trying to run a javascript app on localhost:8000 using docker. Part of what I would like to do is swap out some config files based on the docker run command, I'd like to pass an environment variable into the container so that the bash script can use that as a parameter.
What my dockerfile is looking like is this:
FROM nginx
COPY . /usr/share/nginx/html
CMD ["bash","/usr/share/nginx/html/runfile.sh"]
And the bash script looks like this:
#!/bin/bash
if [ "$SECURITY_VERSION" = "OPENAM" ]; then
sed -i -e 's/localhost/openam/g' authConfig.js
fi
docker run -p 8000:80 missioncontrol:latest -e SECURITY_VERSION="TEST"
Docker gives me an exception saying -e exec command not found.
However if I change the dockerfile to use ENTRYPOINT instead of CMD, the -e flag works but the webserver does not start up.
Is there something I'm missing here? Is the ENTRYPOINT being overriden or something?
EDIT:
So I've updated my dockerfile to use ENTRYPOINT ["bash","/usr/share/nginx/html/runfile.sh", ";", " nginx -g daemon off;"]
But the docker container still shuts down. Is there something I'm missing?
NGINX 1.19 has a folder /docker-entrypoint.d on the root where place startup scripts executed by thedocker-entrypoint.sh script. You can also read the execution on the log.
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will
attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in
/docker-entrypoint.d/
/docker-entrypoint.sh: Launching
[..........]
/docker-entrypoint.sh: Configuration complete; ready for start up
For my future self and everybody else, this is how you can set up variable substitution at startup (for nginx, may also work for other images):
I've also wrote a more in depth blog post about it: https://danielhabenicht.github.io/docker/angular/2019/02/06/angular-nginx-runtime-variables.html
Dockerfile:
FROM nginx
ENV TEST="Hello variable"
WORKDIR /etc/nginx
COPY ./substituteEnv.sh ./substituteEnv.sh
# Execute the subsitution script and pass the path of the file to replace
ENTRYPOINT ["./substituteEnv.sh", "/usr/share/nginx/html/index.html"]
CMD ["nginx", "-g", "daemon off;"]
subsitute.sh: (same as #Daniel West's answer)
#!/bin/bash
if [[ -z $1 ]]; then
echo 'ERROR: No target file given.'
exit 1
fi
#Substitute all environment variables defined in the file given as argument
envsubst '\$TEST \$UPSTREAM_CONTAINER \$UPSTREAM_PORT' < $1 > $1
# Execute all other paramters
exec "${#:2}"
Now you can run docker run -e TEST="set at command line" -it <image_name>
The catch was the WORKDIR, without it the nginx command wouldn't be executed. If you want to apply this to other containers be sure to set the WORKDIR accordingly.
If you want to do the substitution recursivly in multiple files this is the bash script you are looking for:
# Substitutes all given environment variables
variables=( TEST )
if [[ -z $1 ]]; then
echo 'ERROR: No target file or directory given.'
exit 1
fi
for i in "${variables[#]}"
do
if [[ -z ${!i} ]]; then
echo 'ERROR: Variable "'$i'" not defined.'
exit 1
fi
echo $i ${!i} $1
# Variables to be replaced should have the format: ${TEST}
grep -rl $i $1 | xargs sed -i "s/\${$i}/${!i}/Ig"
done
exec "${#:2}"
I know this is late but I found this thread while searching for a solution so thought I'd share.
I had the same issue. Your ENTRYPOINT script should also include exec "$#"
#!/bin/sh
set -e
envsubst '\$CORS_HOST \$UPSTREAM_CONTAINER \$UPSTREAM_PORT' < /srv/api/default.conf > /etc/nginx/conf.d/default.conf
exec "$#"
That will mean the startup CMD from the nginx:alpine container will run. The above script will inject the specified environment variables into a config file. By doing this in runtime yo can override the environment variables.
Update the CMD line as below in the your dockerfile. Please note that if runfile.sh does not succeed (exit 0; inside it) then the next nginx command will not be executed.
FROM nginx
COPY . /usr/share/nginx/html
CMD /usr/share/nginx/html/runfile.sh && nginx -g 'daemon off;'
nginx docker file is using a CMD commnd to start the server on the base image you use. When you use the CMD command in your dockerfile you overwrite the one in their image. As it is mentioned in the dockerfile documentation:
There can only be one CMD instruction in a Dockerfile. If you list more than one CMD then only the last CMD will take effect.
NginX image has docker-entrypoint.d included and on container start will look for any scripts located in there. You can add your custom scripts during docker build. I also found that if you are using alpine image, bash is not installed, so you can add it yourself by running:
RUN apk update
RUN apk upgrade
RUN apk add bash
sample DockerFile:
FROM nginx:alpine
EXPOSE 443
EXPOSE 80
RUN apk update
RUN apk upgrade
RUN apk add bash
COPY ["my-script.sh", "/docker-entrypoint.d/my-script.sh"]
RUN chown nginx:nginx /docker-entrypoint.d/my-script.sh
USER nginx
In order to limit scope execution of your custom script script, it's highly recommended to run your container as a non-privileged user.
nginx container already defines ENTRYPOINT. If you define also CMD it will combine them both like 'ENTRYPOINT CMD' in such way that CMD becomes argument of ENTRYPOINT. That is why you need to redefine ENTRYPOINT to get it working.
Usually ENTRYPOINT is defined in such way, that if you also pass CMD, it will be executed by ENTRYPOINT script. However this might not be case with every container.

Where to put phantomjs script in symfony?

I want to run bash command phantomjs myAwesomeScript.js "www.example.com" from symfony service by using this line:
$response = exec("phantomjs $scriptPath $arguments");
Where can I put my script myAwesomeScript.js? Can I, for example, put this in app/exec/trollingUrl.js? or should I put this in another location?
How to correctly get path to this file in symfony?
Install phantomJS with npm install -globabl phantomjs
PhantomJS will be installed in you're /usr/local if you're running under a unix system.
It means that il will be accessible on you command line from everywhere
After installing it globably you'll just have to do <?php exec("phantomjs $scriptPath $arguments"); ?> in any of you're php script without worrying about phantomjs installation path
More information about global instalation here :
http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation

Categories