I am new to using Linux/Unix command. I have a command that creates a Jmeter file and then in log checks if the generated Jmeter file (If there is any error in Jmeter file it will show error in percentage). If the log has some errors it provides Failure. During this process I get outcome as Failure or Success but the file does not get generated. How can I modify the command so that file gets generated as well as able to check error.
if jmeter -n -t $JMX_FILE -Jurl=$TEST_URL -Jthreads=1 -Jrampup=1 -Jcount=1 -Jsla=$SLA -f -l jmeter-results.jtl | grep "0 (0.00%)$"
then
echo Success
exit 0
else
echo Failure
exit 1
fi
I am trying to compile a software environment in Cygwin using make -j command and this error always shows up.
!error Hello World>
/bin/sh: -c: line 0: syntax error near unexpected token 'newline'
make: ***[makefile:404: ] Error 1
I am using the following code in a chef recipe:
bash 'replace_text' do
cwd ::File.dirname('/data01/nodemanager/bin')
code <<-EOH
sed 's/NODEMGR_HOME=.*/NODEMGR_HOME="\/data01\/nodemanager"/g' startNodeManager.sh
EOH
end
The text that I am trying to replace is everything on the line containing NODEMGR_HOME= startNodeManager.sh located at /data01/nodemanager/bin
and I am receiving the following output when running the recipe:
Running handlers:
[2017-11-21T23:58:22+00:00] ERROR: Running exception handlers
[2017-11-21T23:58:22+00:00] ERROR: Running exception handlers
Running handlers complete
[2017-11-21T23:58:22+00:00] ERROR: Exception handlers complete
[2017-11-21T23:58:22+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 01 seconds
[2017-11-21T23:58:22+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2017-11-21T23:58:22+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2017-11-21T23:58:22+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-11-21T23:58:22+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-11-21T23:58:22+00:00] ERROR: bash[replace_text] (domain-test::sed2 line 1) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "bash" "/tmp/chef-script20171121-11258-vwwwm6" ----
STDOUT:
STDERR: sed: -e expression #1, char 34: unknown option to `s'
---- End output of "bash" "/tmp/chef-script20171121-11258-vwwwm6" ----
Ran "bash" "/tmp/chef-script20171121-11258-vwwwm6" returned 1
[2017-11-21T23:58:22+00:00] ERROR: bash[replace_text] (domain-test::sed2 line 1) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "bash" "/tmp/chef-script20171121-11258-vwwwm6" ----
STDOUT:
STDERR: sed: -e expression #1, char 34: unknown option to `s'
---- End output of "bash" "/tmp/chef-script20171121-11258-vwwwm6" ----
Ran "bash" "/tmp/chef-script20171121-11258-vwwwm6" returned 1
[2017-11-21T23:58:22+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
[2017-11-21T23:58:22+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>> Converge failed on instance <default-ubuntu-1404>. Please see .kitchen/logs/default-ubuntu-1404.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
You don't have enough levels of escaping on your backslashes. Remember it's a Ruby string first, then a bash string, then a sed argument. Also you can sidestep this whole issue by using the line or poise-file cookbooks instead.
I am trying to run a simple one-rule snakemake file as following:
resources_dir='resources'
rule downloadReference:
output:
fa = resources_dir+'/human_g1k_v37.fasta',
fai = resources_dir+'/human_g1k_v37.fasta.fai',
shell:
('mkdir -p '+resources_dir+'; cd '+resources_dir+'; ' +
'wget ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/technical/reference/human_g1k_v37.fasta.gz; gunzip human_g1k_v37.fasta.gz; ' +
'wget ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/technical/reference/human_g1k_v37.fasta.fai;')
But I get an error as :
Error in job downloadReference while creating output files
resources/human_g1k_v37.fasta, resources/human_g1k_v37.fasta.fai.
RuleException:
CalledProcessError in line 10 of
/lustre4/home/masih/projects/NGS_pipeline/snake_test:
Command 'mkdir -p resources; cd resources; wget ftp://ftp-
trace.ncbi.nih.gov/1000genomes/ftp/technical/reference/human_g1k_v37.fasta.gz; gunzip human_g1k_v37.fasta.gz; wget ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/technical/reference/human_g1k_v37.fasta.fai;' returned non-zero exit status 2.
File "/lustre4/home/masih/projects/NGS_pipeline/snake_test", line 10, in __rule_downloadReference
File "/home/masih/miniconda3/lib/python3.6/concurrent/futures/thread.py", line 55, in run
Removing output files of failed job downloadReference since they might be corrupted:
resources/human_g1k_v37.fasta
Will exit after finishing currently running jobs.
Exiting because a job execution failed. Look above for error message
I am not using the threads option in snakemake. I can not figure out how this is related with thread.py. Anybody has experience with this error?
When a shell command fails, it has an exit status which is not 0.
This is what "returned non-zero exit status 2" indicates.
One of your shell command fails, and the failure is propagated to snakemake. I suppose that snakemake uses threads and that the failure manifests itself at the level of some code in the threads.py file1.
In order to better understand what is happening, we can capture the first error using the || operator followed by a function issuing an error message:
# Define functions to be used in shell portions
shell.prefix("""
# http://linuxcommand.org/wss0150.php
PROGNAME=$(basename $0)
function error_exit
{{
# ----------------------------------------------------------------
# Function for exit due to fatal program error
# Accepts 1 argument:
# string containing descriptive error message
# ----------------------------------------------------------------
echo "${{PROGNAME}}: ${{1:-"Unknown Error"}}" 1>&2
exit 1
}}
""")
resources_dir='resources'
rule downloadReference:
output:
fa = resources_dir+'/human_g1k_v37.fasta',
fai = resources_dir+'/human_g1k_v37.fasta.fai',
params:
resources_dir = resources_dir
shell:
"""
mkdir -p {params.resources_dir}
cd {params.resources_dir}
wget ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/technical/reference/human_g1k_v37.fasta.gz || error_exit "fasta download failed"
gunzip human_g1k_v37.fasta.gz || error_exit "fasta gunzip failed"
wget ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/technical/reference/human_g1k_v37.fasta.fai || error_exit "fai download failed"
"""
When I run this, I get the following message after the messages of the first download:
gzip: human_g1k_v37.fasta.gz: decompression OK, trailing garbage ignored
bash: fasta gunzip failed
It turns out that gzip uses a non-zero exit code in case of warnings:
Exit status is normally 0; if an error occurs, exit status is 1. If a warning occurs, exit status is 2.
(from the DIAGNOSTICS section of man gzip)
If I remove the error-capturing || error_exit "fasta gunzip failed", the workflow is able to complete. So I don't understand why you had this error in the first place.
I'm surprised that gzip authors decided to use a non-zero status in case of a simple warning. They added a -q option to turn off this specific warning, due to the presence of trailing zeroes, but strangely, the exit status is still non-zero when this option is used.
1 According to Johannes Köster, author of snakemake:
Sorry for the misleading thread.py thing, this is just the place where snakemake detects the problem. The real issue is that your command exits with exit code 2, which indicates an error not related to Snakemake
When I'm trying to run riscv emulator asm tests I faced with below error:
./emulator-DefaultCPPConfig +dramsim +max-cycles=100000000 +verbose +loadmem=output/rv64ui-p-amoand_d.hex none 2> output/rv64ui-p-amoand_d.out && [ $PIPESTATUS -eq 0 ]
/bin/sh: 1: [: -eq: unexpected operator
make: *** [output/rv64ui-p-amoand_d.out] Error 2
I followed your instruction in your git. It can build emulator without any error, but problem happens when it's trying to run tests.
I added bash behind of the command in the makefile and the first error solved but when I did that I got a new error:
bash ./emulator-DefaultCPPConfig +dramsim +max-cycles=100000000 +verbose +loadmem=output/rv64ui-p-amoswap_d.hex none 2> output/rv64ui-p-amoswap_d.out && [ $PIPESTATUS -eq 0 ]
make: *** [output/rv64ui-p-amoswap_d.out] Error 126
The problem is from Shell variable, I just needed to add following line to Makefile:
SHELL=/bin/bash
It would solve the problem.