Questions tagged [error-handling]

Use this tag for questions on how to handle errors generated in shell scripts.

Filter by
Sorted by
Tagged with
1
vote
0answers
2k views

Repeated error : #error “Only <glib.h> can be included directly.”

I have a research on author attribution compression distance. And I should use "Complearn" ,which is a compression program, in my work. But in the beginning I have problem in installing this program. ...
0
votes
1answer
327 views

How to resolve [1]+ Exit 1 error?

I want to run four different R codes on linux batch using the following command: nohup R CMD BATCH code_name.R& I could run 2 of the codes on background, but running the other two codes, I get ...
0
votes
1answer
289 views

crontab error with installation

I have a problem to install cron task on debian server. It was working on my mint station, but when I implement it to crontab and try to install it, it is not working. Can you help me please? User ...
46
votes
4answers
128k views

How to exit a shell script if one part of it fails?

How can I write a shell script that exits, if one part of it fails? For example, if the following code snippet fails, then the script should exit. n=0 until [ $n -ge 5 ] do gksu *command* &&...
6
votes
1answer
2k views

“set -e” does not terminate script when error occurs in conditional

The following script has a syntax error or error of some sort: #!/usr/bin/env bash set -euo pipefail if [ ! -f /custom.log]; then echo "test" fi abcxyz The script fails with output of: ./test.sh:...
0
votes
0answers
1k views

E: Unable to locate package libboost / libxerces E: Package 'libzeroc-ice-java' has no installation candidate

I am trying to install RebeccaAIML dependecies as it says here: https://github.com/codeanticode/chatbots-library/wiki/Linux-installation-of-RebeccaAIML , by this command: apt-get install libboost ...
5
votes
1answer
9k views

Bash 'unbound variable' error when variables are referenced in multiline comment (set -u) [duplicate]

I have an unexpected behaviour- following snippet fail with 'unbound variable' error: #!/bin/bash set -u <<EOF a=a b=$a EOF Tested on: GNU bash, version 4.4.12(1)-release GNU bash, version 4....
0
votes
1answer
1k views

550 Filename invalid

I have a script that generate a log and in the end of the script i move the log to a windows server. The connection between the 2 servers is fine, if i try to send the files manually it works good. ...
2
votes
1answer
142 views

Cannot add snappy-dev/tools ppa repository

I am using Deepin Linux 15.4.1 and I want to install the package snapcraft (to do that I need the "title's repository"), when I try to add the snappy-dev/tools repository with the command: sudo add-...
1
vote
1answer
793 views

How to Group Commands After '&&' or '||' Branch and Not Invoke Subshell Variable Restriction? [duplicate]

This script just tries to copy file foo to bar/, and if it`s unsuccessful, retries 2 more times. EDIT: as it turns out, the reason the second example works and the first does not, is because the use ...
0
votes
1answer
623 views

error: ‘TCP_NODELAY’ was not declared in this scope [closed]

I am trying to compile ChatScipt v7.55 in Ubuntu 16.04. But when I use make server command, I get this error: evserver.cpp: In function ‘int settcpnodelay(int)’: evserver.cpp:263:40: error: ‘...
0
votes
0answers
1k views

collect2: error: ld returned 1 exit status Makefile:107: recipe for target ‘binary’ failed make: *** [binary] Error 1

I am trying to compile ChatScript V7.55 on Ubuntu 16.04 but I got this error message: collect2: error: ld returned 1 exit status Makefile:107: recipe for target ‘binary’ failed make: *** [binary] ...
0
votes
0answers
474 views

Error opening audio device (null) for capture: Connection refused FATAL: “continuous.c”, line 245: Failed to open audio device

I am trying to install pocketsphinx on my ARM-based board(nanopi-m1), and use Ubuntu-Core 16.04 on it. But when I try to test pocketsphinx with this command: pocketsphinx_continuous -inmic yes I get ...
2
votes
3answers
484 views

feh warns on text files

How do I get rid of these warnings from feh? I am trying to run a slideshow using images in a directory. Why is feh trying to open text files in that directory? feh WARNING: images/temp.txt - No ...
2
votes
0answers
425 views

libtool: error: relink 'libpocketsphinx.la' with the above command before installing it

When I trying to install pocketsphinx by make install command(after ./autogen.sh , ./configure, make commands) , I get this error message: libtool: error: relink 'libpocketsphinx.la' with the above ...
2
votes
2answers
108 views

Preventing shell from exiting when set -e is turned on?

I have set -e turned on for my script. The only thing is there is one command here that I don't want causing the script to exit if it fails, but I want everything else to do that. How can I keep set -...
0
votes
2answers
732 views

How to solve building error where a variable “… was not declared in this scope”

I'm trying to install last TauDEM (Terrain Analysis Using Digital Elevation Models) release in GNU/Linux Debian for using with Python Processing in QGIS. Installing instructions can be watched here. ...
1
vote
0answers
235 views

Linux type cast output difference [closed]

I'm using 'gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55)'. Below is my question. I don't know why #1, #2 result is different. unsigned int A, B, C, D, E; double result; 1. A=28; B=10; D=5; C = ((...
4
votes
0answers
41 views

Behavior of set -e in function calls [duplicate]

I have an unusual problem with -e flag in a following bash script: #!/bin/bash -e foo() { return 1; } bar() { foo; bar; } bar || exit 1 Namely the script does not terminate, even though the foo ...
1
vote
1answer
3k views

Bash script to select files to zip/unzip

I'm trying to zip and unzip files with a bash script, but I'm new and I have problems. I will explain what the script currently does, and then what I wanted it to do. User selects “compress”: a file ...
1
vote
3answers
622 views

Error cleanup for shell scripts

What's the best way to include error cleanup logic for shell scripts? Specifically, I have a script that does something like this: mount a x mount b y setup_thing mount c z do_something umount z ...
0
votes
2answers
818 views

Error Code on Prompt

Currently I have ! in the right prompt of zsh as follows: export RPS1="%B%F{red}!%f%b" As I use tmux, and command history is not being synced throughout its panes (unfortunately), the numbers are ...
4
votes
0answers
321 views

Distinguish between error and “success” in scanimage-batch

I'm running a little script with the scanimage batch-command on a remote server and would like to know if and how the scan has been done the batch. Therefore the script requires a proper "error"-...
3
votes
1answer
3k views

How to save psql error message output in bash variable?

I have a script that runs several different psql statements. I'm trying to capture the error output from psql when password entered is incorrect. The password is entered in before the check (and when ...
0
votes
1answer
158 views

Trouble installing Deco-IDE on Ubuntu 16.04 - .sh file keeps throwing a postscript ngrok error

Ive been trying to install Deco-IDE on Ubuntu 16.04 linux through this hack I found on github but I keep getting an error seen in the image below after the lines: cd ../../Desktop npm install I ...
7
votes
2answers
25k views

How to use $? and test to check function?

#!/bin/sh function checkExit(){ if test "$?" != "0"; then echo Command $1 exited with abnormal status exit 1; else echo $? fi } function echoThenRun () { # echo and then run ...
1
vote
1answer
610 views

How to avoid error-message during the execution of a bash script?

I need to write a bash-script which will find all files with name string.h on the computer and copy them to some folder. My code is here: #!/bin/bash sudo find / -type f -name "string.h" -exec cp {} ...
5
votes
4answers
28k views

Can I fix bad blocks on my hard disk with a single command?

I'm working on fixing the errors in my Hard Disk, It's possible to do that manually but it might take hours. After typing this command sudo badblocks -b 512 /dev/sda, I got hundreds of results and I ...
0
votes
4answers
12k views

apt-get update failed to fetch and /sources.list.d/ empty

Running the sudo apt-get update command, I got the following error: Fetched 988 kB in 16s (59,3 kB/s) W: Failed to fetch http://old-releases.ubuntu.com/...
0
votes
1answer
349 views

Is there a way to attach an error handler to bash scripts?

Is there a way to add an error handler to bash, which executes if any given command in the script fails? I'm aware of set -o errexit, but that doesn't allow me to add a custom error handler.
3
votes
1answer
588 views

Getmail: Connection reset by peer (IMAP Idle)

I am trying to receive mails using getmail from an IMAP Idle server. Since I am able to receive mails using Mac OS' Mail app from another account on the same server (mail adress provider), IMAP Idle ...
2
votes
1answer
672 views

How to cause an error 77 EBADFD in Linux

What's a quick shell script, Python script, or C program that can be written to cause it to exit with error code 77 i.e. EBADFD? I don't want to just say for example exit 77, I want it to do something ...
1
vote
3answers
2k views

Debian live iwlwifi firmware error

When booting Debian live onto my computer, I encountered the errors: [ 19.456064] iwlwifi 0000:03:00.0: firmware: failed to load iwlwifi-7265-9.ucode (-2) [ 19.456183] iwlwifi 0000:03:00.0: ...
0
votes
1answer
797 views

Apache 2.4.25 Make failed due to PCRE cannot find pcre.h

I use Solaris 11. pcre.h exist in /opt/app/pcre/lib but Make cannot detect it.How can I include /opt/app/pcre/lib during make? Apache 2.4.25 configure: CC='/opt/app/solarisstudio12.4/bin/cc' CPP='/...
1
vote
4answers
127 views

Is there a way to force program to output errors in English?

When I run into errors I sometimes get errors in my language set by locale. Is there a way besides switching locale to force English error messages for the sake of googling the solution?
2
votes
3answers
4k views

Does “226 Transfer complete” guarantee the consistency between local and remote files when using ftp?

I have some automated scripts which perform FTP uploads among other things. I'm wondering what level of error checking I should conduct once these uploads have finished executing. Could anything go ...
13
votes
4answers
2k views

How do I capture the exit code / handle errors correctly when using process substitution?

I have a script that parses file names into an array using the following method taken from a Q&A on SO: unset ARGS ARGID="1" while IFS= read -r -d $'\0' FILE; do ARGS[ARGID++]="$FILE" done &...
3
votes
0answers
3k views

Wifi too much “Invalid misc”, how to fix it?

Here are some outputs: root@debian:/home/love# iwconfig wlan0 wlan0 IEEE 802.11bgn ESSID:"SITI_Broadband-06E6-G" Mode:Managed Frequency:2.412 GHz Access Point: FC:4A:E9:4B:06:E8 ...
10
votes
3answers
2k views

Is there a way to have a function in my bash script auto run on any command error?

I'm writing a shell script that needs to do a bunch of commands and every command depends on every previous command. If any command fails the entire script should fail and I call an exit function. I ...
1
vote
2answers
86 views

Move directories despite of errors

When moving a directory to another drive, if there are errors in the process, nothing will be deleted. I am getting this kind of errors: mv: cannot stat ‘originaldirectory/longpath/irrelevantfile’: ...
-2
votes
1answer
735 views

Error installing anything on Kali 2.0

I changed from 32bit to 64bit and i cant install anything. As soon as i installed the OS i used apt-get update and apt-get upgrade. Now everything i try to install i get the following error. Reading ...
1
vote
1answer
526 views

How to define a function that handles `command not found`?

I'd like to define a function that is called, whenever a shell-user types a command that does not exist. In my case I'd like to log the errors and try alternative commands. currently, when typing e.g....
1
vote
0answers
48 views

STDERR redirection without intermediate file

Here is a toy shell script: #!/bin/bash set -e misspelled_command exec > run_$( date +%Y%m%d ).log 2>&1 echo "Logging" exit If I submit with nohup bash raise_errors.sh > /dev/null 2&...
12
votes
1answer
26k views

What are the standard error codes in Linux?

When I write a code in bash for instance that copies a file, when the file doesn't exist, in the terminal I see an error similar to "file not found", if the script user isn't granted the permission ...
0
votes
1answer
2k views

“The specified directory 'media/fa/FAF9-!C03' is not valid” Error when trying to open USB sticks!

I have an ARM-based computer(nanopi m1) that has 3 USB ports that all work good with other devices like mouse, keyboard, wireless dongle. but when I try any USB flash memories it doesn't work! What's ...
76
votes
2answers
22k views

Why is pattern “command || true” useful?

I am currently exploring Debian packages, and I have been reading some code samples. And on every line in, for example, the postinst script is a pattern. some command || true another command || true ...
0
votes
1answer
201 views

apt vs apt-get error code

Strange thing I have here, when apt is locked by something. Respectively, the error codes don't match up. apt update seems to always return success 0, whereas apt-get update returns a proper error ...
2
votes
1answer
175 views

Fedora 15 updates

I have a dual booted system, and its been years since I have used the linux side. I am running Fedora15 and am trying to upgrade. I have tried yum install preupgrade and I get the error message ...
0
votes
2answers
653 views

Running command multiple times and trigger report on failure

I am trying to run the "make" command on my project 100 times. But, obviously I wouldn't be monitoring the results but I would like to know when the build fails. How would I go about making it ...
3
votes
3answers
4k views

Apache not binding to port 80?

I am having issues with Apache. I just installed Centos and waant to create a webserver of my own. I am following the directions of "the perfect server for centos 7.2" and came upon this error on my ...