Sponsored Content
Full Discussion: Detect error and exit
Top Forums Shell Programming and Scripting Detect error and exit Post 302991388 by sitaram on Friday 10th of February 2017 12:12:51 AM
Old 02-10-2017
Detect error and exit

Hi,

I am using Jenkins and have integrated JMeter for testing. JMeter is generating a file with results properly using shell script. I have to validate the results and exit the shell with non-zero so my jenkins job gets failed. I tried multiple ways to grep the output file and read the results in an array but its not working.

I gave a grep command, but got to remove '(' and ')' as shell is not accepting so this is not converting to array

Error :
Code:
array=($(grep -oP '(?<=error>)[^<]+' "TestCases/results.jtl") )

accepted by shell:
Code:
array=$(grep -oP '(?<=error>)[^<]+' "TestCases/results.jtl")


Below is the file , using shell script I have to exit when 'error' count with value true is greater than 1.


results.jtl File :

Code:
<testResults version="1.2">
<httpSample t="73" it="0" lt="0" ct="65" ts="1486696391218" s="false" lb="LoopbackRequest" rc="Non HTTP response code: org.apache.http.NoHttpResponseException" rm="Non HTTP response message: 192.168.99.100:2011 failed to respond" tn="DPIntegration_Testing 1-1" dt="text" by="2249" sby="0" ng="1" na="1">
  <assertionResult>
    <name>XPath Assertion</name>
    <failure>false</failure>
    <error>true</error>
    <failureMessage>SAXException: Content is not allowed in prolog.</failureMessage>
  </assertionResult>
</httpSample>

<httpSample t="70" it="0" lt="0" ct="63" ts="1486696392639" s="false" lb="LoopbackRequest" rc="Non HTTP response code: org.apache.http.NoHttpResponseException" rm="Non HTTP response message: 192.168.99.100:2011 failed to respond" tn="DPIntegration_Testing 1-1" dt="text" by="2249" sby="0" ng="1" na="1">
  <assertionResult>
    <name>XPath Assertion</name>
    <failure>false</failure>
    <error>true</error>
    <failureMessage>SAXException: Content is not allowed in prolog.</failureMessage>
  </assertionResult>
</httpSample>

</testResults>

Can someone please help me with this ?

Thanks.

Last edited by Scrutinizer; 02-10-2017 at 01:18 AM.. Reason: code tags
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Where can I find a list of exit codes? (Exit code 64)

I'm receiving an exit code 64 in our batch scheduler (BMC product control-m) executing a PERL script on UX-HP. Can you tell me where I can find a list of exit codes and their meaning. I'm assuming the exit code is from the Unix operating system not PERL. (3 Replies)
Discussion started by: jkuchar747
3 Replies

2. Shell Programming and Scripting

exit on error - is it possible?

Hi , i have shell scripts that run the mysql directly by echoing and redirecting the output to the mysql logins. whenever the query executes successfully then the script runs fine and nothing has to be done there. Now, when there is an error executing the query then it will generate the error... (8 Replies)
Discussion started by: ahmedwaseem2000
8 Replies

3. Linux

tar error exit delayed form pervious error

Hi when use "tar cpvzf /dev/st0 --exclude=/proc --exclude-/lost+found --exclude=/mnt --exclude=/media --exclude=/sys /" to tape, get the following message "tar: error exit delayed form pervious error", What is the mean ? Please suggest some solution for these errors. thx (1 Reply)
Discussion started by: chayato
1 Replies

4. Shell Programming and Scripting

exit out of a while loop with error

im running a while loop as a file watcher, with incremental counter on the retries..however when the retries reach it's limit i want it exit and echo and error and stop the batch. Im not sure the code i have will do that already... Here is what i have that works: #!/usr/bin/ksh count=0... (2 Replies)
Discussion started by: sigh2010
2 Replies

5. Shell Programming and Scripting

set a variable and detect error status...

Hi there, I'm driven crazy by a new problem. It seems very complex to me and I see no way to come around. In my script, I receive the path to a tgz file and I want to output the md5 sum of the file inside the tgz. I want a way to detect if tar fails. I'm using the following command tar... (7 Replies)
Discussion started by: chebarbudo
7 Replies

6. UNIX for Dummies Questions & Answers

aCC exit error

Hi guys I would just like to know if aCC supports the command exit(0); in c++? I am always getting the error below: Error 328: "ac5.C", line 37 # Function 'exit' has not been defined yet; cannot call. exit(0); ^^^^ Anyone had this problem? Thanks! (2 Replies)
Discussion started by: khestoi
2 Replies

7. Shell Programming and Scripting

If Error then Exit

HI I am just using cd Command and i want exit if error. Ex. cd /hp/pp/0720 If above folder in not available then stop the script Folder is change every day Thanks (3 Replies)
Discussion started by: asavaliya
3 Replies

8. Shell Programming and Scripting

How to exit a script with error ?

Hi, I have a script ABC which calls another script XYZ. Function of XYZ is to ftp a file from one server to another. code for ABC: #!/bin/ksh PATH=/usr/bin home/user/xyz "$@" exit $? ~ code for xyz: #!/bin/ksh HOSTNAME=$1 SRCNAME=$2 DSTNAME=$3 (4 Replies)
Discussion started by: Salil Gupta
4 Replies

9. Shell Programming and Scripting

FTP exit and error codes

I have a script which connects to a remote server via FTP and gets some file from there. #!/bin/bash /usr/bin/ftp -n remote.hostname.com <<EOF quote USER user123 quote PASS password123 lcd /dir1/dir2/dir3 cd / mget file_pattern* close bye EOF rc=$? if ] ... (7 Replies)
Discussion started by: dhruuv369
7 Replies
platform::shell(n)					       Tcl Bundled Packages						platform::shell(n)

__________________________________________________________________________________________________________________________________________________

NAME
platform::shell - System identification support code and utilities SYNOPSIS
package require platform::shell ?1.1.4? platform::shell::generic shell platform::shell::identify shell platform::shell::platform shell _________________________________________________________________ DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell. This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only requirement is that the other shell (identified by its path), is actually executable on the current machine. While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run 32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers. For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed packages, versus the architecture of the shell running the repository software. COMMANDS
platform::shell::identify shell This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell. platform::shell::generic shell This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell. platform::shell::platform shell This command returns the contents of tcl_platform(platform) for the specified Tcl shell. KEYWORDS
operating system, cpu architecture, platform, architecture platform::shell 1.1.4 platform::shell(n)
All times are GMT -4. The time now is 08:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy