exit-code

CalledProcessError exit status code 5

爷,独闯天下 提交于 2019-12-24 14:07:12
问题 I have been working with a short python script that executes bash commands. The program worked fine for about a month. Recently, I tried running the script passing it this command: my_launcher.py -c /path/to/config/file.json (BTW, when the command is entered in terminal, I causes no error and runs fine) and I get the following message: RuntimeError: Command '['bash', '-c', 'my_launcher.py -c /path/to/config/file.json']' returns non-zero exit status (code5) After looking on Google, I found

Checking the exit code of a CLI in a test

时光总嘲笑我的痴心妄想 提交于 2019-12-24 07:45:40
问题 I am writing automated tests for a command line tool. Essentially, I want to invoke the CLI with various options and test the exit code and/or output. My test looks like this: from mymodule.cli_tool import main def test_args(capfd): with pytest.raises(SystemExit) as e: main(args=['--junk_option']) # check the exit code to make sure it is non-zero ??? How do I check the exit code? 回答1: You need to check value.code , like this: assert e.value.code != 0 来源: https://stackoverflow.com/questions

Capturing in PowerShell different sqlcmd exitcode for connectivity/data issues

社会主义新天地 提交于 2019-12-24 06:49:31
问题 I am calling sqlcmd from PowerShell to execute a T-SQL script. Currently I am using ":On Error exit" to exit the script if there is an error caused by the data used violating a constraint etc. This is handled by PowerShell detecting the $SqlcmdProcess.ExitCode of 1. However, if there is a connectivity issue with the database, sqlcmd also gives an ExitCode of 1. Is there a way to set the :On Error ExitCode to something other than 1? I'm aware of using something like :Exit(SELECT 2) to do this,

Capturing in PowerShell different sqlcmd exitcode for connectivity/data issues

情到浓时终转凉″ 提交于 2019-12-24 06:49:29
问题 I am calling sqlcmd from PowerShell to execute a T-SQL script. Currently I am using ":On Error exit" to exit the script if there is an error caused by the data used violating a constraint etc. This is handled by PowerShell detecting the $SqlcmdProcess.ExitCode of 1. However, if there is a connectivity issue with the database, sqlcmd also gives an ExitCode of 1. Is there a way to set the :On Error ExitCode to something other than 1? I'm aware of using something like :Exit(SELECT 2) to do this,

Why is the return value of Perl's system not what I expect?

柔情痞子 提交于 2019-12-24 04:34:06
问题 Let me begin by explaining what I'm trying to accomplish. Essentially there are two Perl scripts. One is what I call the Main script with an UI. The user who runs this script will see a list of other scripts he can call from the menu. This list is loaded through a custom config file. The purpose of the main script is to be able to add other scripts in the future as needed without changing the source and be run either as cron job (Non-Interactive mode) and as the user needs (Interactive Mode).

Nightwatch.js always returns exit code 1

随声附和 提交于 2019-12-24 01:44:08
问题 I try to integrate my Nightwatch.js tests in a Jenkins Job. I want the Jenkins build to fail if the tests will fail and I want the build to pass if all tests will pass. But I recognized that Nightwatch always returns the exit code 1 , doesn't matter if the tests will pass or fail. But I expect that the exit code 0 will be return if all tests will pass. Does anyone have a solution for that issue? I use nightwatch@0.9.19 in combination with nightwatch-cucumber@9.0.0 . This is my Nightwatch call

Capture non-zero exit code from named pipe

徘徊边缘 提交于 2019-12-24 00:24:31
问题 The following toy script ( tmp.sh ) exits with code 0 even if the process sent to the named pipe fails. How can I capture the non-zero exit code from the named pipe? Or more in general, the fact that something has gone wrong? #!/bin/bash set -eo pipefail mkfifo mypipe FOOBAR > mypipe & cat mypipe Run and check exit code: bash tmp.sh tmp.sh: line 6: FOOBAR: command not found echo $? # <- Exit code is 0 despite the "command not found"! 回答1: You need to capture process id of background process

Getting ExitCode From Exception Handler

冷暖自知 提交于 2019-12-23 23:20:23
问题 I have following error handler in my console application Main Procedure: AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ErrorHandler); Handler Procedure: static void ErrorHandler(object sender, UnhandledExceptionEventArgs args) { Exception e = (Exception)args.ExceptionObject; ... Loging Error ... //Environment.Exit(?); } And the problem is that error is logged but after that application failed and windows popup (application is not responding) is showed. So i

Execute process conditionally in Windows PowerShell (e.g. the && and || operators in Bash)

爱⌒轻易说出口 提交于 2019-12-23 08:48:11
问题 I'm wondering if anybody knows of a way to conditionally execute a program depending on the exit success/failure of the previous program. Is there any way for me to execute a program2 immediately after program1 if program1 exits successfully without testing the LASTEXITCODE variable? I tried the -band and -and operators to no avail, though I had a feeling they wouldn't work anyway, and the best substitute is a combination of a semicolon and an if statement. I mean, when it comes to building a

Exit from a console application in C#

狂风中的少年 提交于 2019-12-23 07:54:11
问题 I read a lot of things here on stackoverflow, comments, opinions and every kind of ideas. But anyway, I really need an explained way to exit my console application (I'm on VS2010 Framework 4) on C# with a custom error. The best thing I could read right now is on VB: Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long) and use ExitProcess(1) for an error or ExitProcess(0) So my questions are: Is the same than Environment.Exit(1) ? What is the better for an application that