post form data in apache bench command line tool - apachebench

My endpoint url is as below
curl http://localhost:5000/predict -F file=#/home/ubuntu/sample1.jpg
where the file is passed as -F parameter (form).
I would like to benchmark it using ab command line tool
I tried
ab -n 1 -c 1 -p /home/ubuntu/sample1.jpg http://localhost:5000/predict
and it doesn't work. Is there any equivalent way to mimic -F parameter in ab ?

Related

How to pass parameter expansions into qsub?

I'm trying to use qsub to submit multiple parallel jobs, but I'm running into trouble with passing parameter substitutions into qsub. I'm using the -V option, but it doesn't seem to recognize what ${variable} is. Here's some code I tried running:
qsub -cwd -V -pe shared 4 -l h_data=8G,h_rt=00:10:00,highp -N bt2align3 -b y "projPath="$SCRATCH/CUTnTag/data_kayaokur2020"; sample="K4m3_rep1"; cores=8;
bowtie2 --end-to-end --very-sensitive --no-mixed --no-discordant --phred33 -I 10 -X 700
-p ${cores}
-x ${projPath}/bowtie2_index/GRCh38_noalt_analysis/GRCh38_noalt_as
-1 ${projPath}/raw_fastq/${sample}_R1.fastq.gz
-2 ${projPath}/raw_fastq/${sample}_R2.fastq.gz
-S ${projPath}/alignment/sam/${sample}_bowtie2.sam &> ${projPath}/alignment/sam/bowtie2_summary/${sample}_bowtie2.txt"
I just get an error that says "Invalid null command."
Is qsub not able to recognize parameter expansions? Is there a different syntax I should be using? Thanks.

How to use curl -w switch with multiple data token as format parameter?

I want to get two things from curl: http_code and time_total from a single curl request. How should I formulate the -w %{insert_formatting_here} ?
These works:
result = $(curl -s -w %{http_code} -o temp.txt) "http://127.0.0.1"
echo "$result"
result = $(curl -s -w %{time_total} -o temp.txt) "http://127.0.0.1"
echo "$result"
Result:
200
0.004
But this didn't work as I expected:
result = $(curl -s -w %{http_code time_total} -o temp.txt) "http://127.0.0.1"
echo "$result"
Result:
<p>where "$CATALINA_HOME" is the root of the Tomcat installation directory. If you're seeing this page, and you don't think you should be, then you're either a user who has arrived at new installation of Tomcat, or you're an administrator who hasn't got his/her setup quite right. Providing the latter is the case, please refer to the Tomcat Documentation for more detailed setup and administration in %{http_codeReserved99-2014 Apache Software Foundation<br/>ht="80" alt="Powered by Tomcat"/><br/>s working on Tomcat</li>configuring and using Tomcat</li> developing web applications.</p>
I cannot find any tutorial that helps me to put multiple token on the format parameter. They only list the format token, but there's no example or anything so far.
Each placeholder needs to be in brackets, i.e.:
curl -s -w "%{http_code}:%{time_total}" http://127.0.0.1

Why use -Lo- with curl when piping to bash?

In the janus project, they use curl to download and pipe a bootstrap script into bash.
https://github.com/carlhuda/janus
It looks like this:
$ curl -Lo- https://bit.ly/janus-bootstrap | bash
Why would one want to use the args -Lo-?
-o is supposed to be for output, but wouldn't that happen anyway (i.e. to stdout)?
It's all in the man pages:
-L in case the page has moved (3xx response) curl will redirect the request to the new address
-o output to a file instead of stdout (usually the screen). In your case the o flag is redundant since the output is piped to bash (for execution) - not to a file.
The -o is redundant, they produce the exact same output:
$ curl --silent example.com | sha256sum
3587cb776ce0e4e8237f215800b7dffba0f25865cb84550e87ea8bbac838c423 *-
$ curl --silent --output - example.com | sha256sum
3587cb776ce0e4e8237f215800b7dffba0f25865cb84550e87ea8bbac838c423 *-
They have used that syntax since that line was first introduced in 2011.
You might ask Wael Nasreddine (#kalbasit on GitHub) why he did it. He
is still active on that repo.

Ldap search with negative parameter

I'm trying to do a search on my LDAP base like that:
ldapsearch -x -h localhost -p 389 -D uid=xxxadmin,ou=administrators,ou=topologymanagement,o=netscaperoot -v -w 12345 -b "ou=Usuarios,ou=Alunos,ou=XXXX,o=xxXXXxx" -f (!(objectClass=ntUser)) 1.1
Basically I want to list all the entries without the objectClass ntUser and add the objectClass to them.
I'm getting this as an answer:
-bash: !: event not found
From http://www.openldap.org/lists/openldap-software/200104/msg00196.html
This message comes from the shell (bash). It states that the command
`!' didn't find the event you unintentionally asked for. This happens
because the double quotes in bash do not prevent some command
invocation. Use single quotes instead:
Your search should be like this:
ldapsearch -x -h localhost -p 389 -D 'uid=xxxadmin,ou=administrators,ou=topologymanagement,o=netscaperoot' -v -w 12345 -b 'ou=Usuarios,ou=Alunos,ou=XXXX,o=xxXXXxx' -f '(!(objectClass=ntUser))' 1.1
Your search should work. But, for bash, you will need to quote the parameters.
Something like:
ldapsearch -x -h localhost -p 389 -D uid=xxxadmin,ou=administrators,ou=topologymanagement,o=netscaperoot -v -w 12345 -b "ou=Usuarios,ou=Alunos,ou=XXXX,o=xxXXXxx" -f "(!(objectClass=ntUser))" 1.1
Tested both openLDAP
#(#) $OpenLDAP: ldapsearch (Ubuntu) (Mar 17 2014 21:19:27) $buildd#aatxe:/build/buildd/openldap-2.4.31/debian/build/clients/tools
(LDAP library: OpenLDAP 20431)
ldapsearch -x -h localhost -p 389 -D "cn=admin" -W -b "dc=example,dc=com" -s sub -a always -z 1000 "(!(objectClass=inetOrgPerson))" "objectClass"
and OpenDJ
ldapsearch --version
OpenDJ 2.7.0-20140727
Build 20140727000040Z
ldapsearch -h localhost -p 389 -D "cn=admin" -b "dc=example,dc=com" -s sub -a always -z 1000 "(!(objectClass=inetOrgPerson))" "objectClass"
-jim
Its happening because bash thinks ! as a special character
"!" Start a history substitution, except when followed by a space, tab, the end of the line, ‘=’ or ‘(’
So finally, you should be able to solve your problem by putting single quotes around the term as follow:
ldapsearch -x -h localhost -p 389 -D uid=xxxadmin,ou=administrators,ou=topologymanagement,o=netscaperoot -v -w 12345 -b "ou=Usuarios,ou=Alunos,ou=XXXX,o=xxXXXxx" -f '(!(objectClass=ntUser))' 1.1
Please refer following question on stackoverflow.
Which characters need to be escaped in Bash? How do we know it?

Want to capture grep counts for a command output

I would like to count the occurrence of word ERROR by using command:-
mysql -B -u root -pxxxx -h abc -e show databases | grep -c "ERROR"
However my understanding says it should return 1 however it is returning it as O
Why ?
Also please let me know the significance of mysql -B and -e
Thanks,
Ruchir
Errors go to the standard error (stderr) by default, so you need to redirect it to standard output (via 2>&1). In which case grep can process them:
mysql -B -u root -pxxxx -h abc -e show databases 2>&1 | grep -c "ERROR"

Resources