Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

1 votes
0 answers
51 views
rename "Duplicate specification" for option error
The other day something started going wrong with the perl `rename` terminal command that was pre-installed on my system; which is Ubuntu 22.04.5 LTS. When I try to use any version of the rename command I get the following message: Duplicate specification "V|version" for option "v" Duplicate specific...
The other day something started going wrong with the perl rename terminal command that was pre-installed on my system; which is Ubuntu 22.04.5 LTS. When I try to use any version of the rename command I get the following message: Duplicate specification "V|version" for option "v" Duplicate specification "E=s" for option "e" By this I mean that any attempts at using rename, including simply rename -h bring up this error. rename -h will still print out the help information, which is as follows for my version of rename (2.02)
Duplicate specification "V|version" for option "v"
Duplicate specification "E=s" for option "e"
Usage:
    rename [ -h|-m|-V ] [ -v ] [ -0 ] [ -n ] [ -f ] [ -d ] [ -u [enc]]
    [ -e|-E perlexpr]*|perlexpr [ files ]

Options:
    -v, --verbose
            Verbose: print names of files successfully renamed.

    -0, --null
            Use \0 as record separator when reading from STDIN.

    -n, --nono
            No action: print names of files to be renamed, but don't rename.

    -f, --force
            Over write: allow existing files to be over-written.

    --path, --fullpath
            Rename full path: including any directory component. DEFAULT

    -d, --filename, --nopath, --nofullpath
            Do not rename directory: only rename filename component of path.

    -h, --help
            Help: print SYNOPSIS and OPTIONS.

    -m, --man
            Manual: print manual page.

    -V, --version
            Version: show version number.

    -u, --unicode [encoding]
            Treat filenames as perl (unicode) strings when running the
            user-supplied code.

            Decode/encode filenames using encoding, if present.

            encoding is optional: if omitted, the next argument should be an
            option starting with '-', for instance -e.

    -e      Expression: code to act on files name.

            May be repeated to build up code (like "perl -e"). If no -e, the
            first argument is used as code.

    -E      Statement: code to act on files name, as -e but terminated by
            ';'.
If I attempt any actuall usage of the program, even as simple as rename -n -s/\.txt//' * the program stalls out and freezes after printing the error message. As far as I have been able to find digging around for help and answers, the issue is apparently due to Getopt::Long somehow ignoring case, despite the fact that File::Rename::Options is meant to specifically turn on no_ignore_case when it calls Getopt::Long. I have tried updating, upgrading, and cleaning apt and apt-get, purging and then reinstalling rename, updating/upgrading Perl, along with basic computer updates and restarting. If anyone knows what is going on to cause this, or has a solution, I'd be extremely grateful.
Danae Stephens (11 rep)
Jul 2, 2025, 07:52 PM • Last activity: Jul 3, 2025, 06:05 PM
8 votes
6 answers
15038 views
How to catch and handle nonzero exit status within a Bash function?
Say I have the following (pointless) Bash function: myfunc() { ls failfailfail uptime } I run it as follows: myfunc || echo "Something is wrong." What I want to happen is `ls` runs (as it should), `failfailfail` does not work (since it doesn't exist), and `uptime` doesn't run. The return value of th...
Say I have the following (pointless) Bash function: myfunc() { ls failfailfail uptime } I run it as follows: myfunc || echo "Something is wrong." What I want to happen is ls runs (as it should), failfailfail does not work (since it doesn't exist), and uptime doesn't run. The return value of the function would be nonzero, and the error message would be shown. The return value doesn't have to be the exact exit status of the failed command, it just shouldn't be zero. What actually happens is I get the output of ls, followed by "-bash: failfailfail: command not found", followed by the output of uptime. The error message is not shown, because the failed exit status is getting eaten. set -e has no useful effect, either within the function or in the scope where the function is called. The only way I can get this to work the way I want is: myfunc() { ls || return $? failfailfail || return $? uptime || return $? } But this seems awfully repetitive and ugly. Is there another way to clean this up?
smitelli (308 rep)
Apr 28, 2016, 04:15 PM • Last activity: Jun 23, 2025, 08:08 PM
0 votes
0 answers
31 views
Apache2 PHP error_log() doesn't work when called in some PHP code
On my Linux Ubuntu system I run `apache2` web server in the context of a `PHP` based web application. `phpinfo()` reports the following error_log /opt/unetlab/data/Logs/php_errors.txt I.e. `error_log()` is supposed to send messages to `/opt/unetlab/data/Logs/php_errors.txt` file. On `PHP` code that...
On my Linux Ubuntu system I run apache2 web server in the context of a PHP based web application. phpinfo() reports the following error_log /opt/unetlab/data/Logs/php_errors.txt I.e. error_log() is supposed to send messages to /opt/unetlab/data/Logs/php_errors.txt file. On PHP code that handles the application's REST API, I use error_log() function to log some debugging info. The weird thing is that sometimes error_log() doesn't write anything on the log file. Nevertheless error_log() called from other PHP code's files (e.g.functions.php) works as a charm. Which could be the problem ?
CarloC (385 rep)
Jun 4, 2025, 02:06 PM • Last activity: Jun 5, 2025, 05:56 AM
2 votes
2 answers
2902 views
How to make systemd not hang (unresponsive system), but provide emergency shell?
I am not very familiar with systemd. The answer I seek with this question is: How is it possible to make **systemd** react to problems with "dropping the user into an emergency shell of sorts", instead of simply having an unresponsive system? Example for being explicit: Case of an install of arch li...
I am not very familiar with systemd. The answer I seek with this question is: How is it possible to make **systemd** react to problems with "dropping the user into an emergency shell of sorts", instead of simply having an unresponsive system? Example for being explicit: Case of an install of arch linux on a thinkpad, it seems that there is some miscofiguration of the x-org-server, or wayland, or maybe systemd, or lightdm, which instead of producing a error message leaves the user hung up. This means that the user sees the service/startup messages being output to tty1 come to stop, without any having any error message produced (if there is one the glorious **systemd-journald** ate it??) and no key combination whatsoever can even produced a root shell to enable the user to check for the error and correct it. Consequenlty the answer how to configure systemd to drop into a emergency shell to avoid a hung up system at any error, on the way to a **graphical.target** How such a hung up situation might be like is done for instance in this U&L question "arch-linux-hang-on-reached-target-graphical-interface "
humanityANDpeace (15072 rep)
Jun 12, 2018, 02:56 PM • Last activity: May 18, 2025, 10:01 PM
11 votes
3 answers
11770 views
Best practice to use $? in bash?
When I read this [answer about $?][1] another question comes to mind. Is there any best practice for how to use $? in bash? ---- Let's have a example: We have a linear script and I we would like to know that all the command was executed ok. Do you think it is ok to call a small function (let's call...
When I read this answer about $? another question comes to mind. Is there any best practice for how to use $? in bash? ---- Let's have a example: We have a linear script and I we would like to know that all the command was executed ok. Do you think it is ok to call a small function (let's call it "did_it_work"), to check the error code and break if it's not. #!/bin/bash function did_it_work { code=$1 if [ "$code" -ne "0" ] then echo "Error failure: code $code " exit 1 fi } dir=some/path mkdir -p $dir did_it_work $? cd $dir did_it_work $? run_some_command did_it_work $? This approach of course means that I have to manually solve the problem if there is any and rerun the script. Do you think this is a good idea or is there some other best practice to do this? /Thanks
Johan (4671 rep)
Mar 7, 2011, 04:35 PM • Last activity: May 12, 2025, 09:51 PM
11 votes
3 answers
29487 views
How to transfer files from linux to iphone?
I have the ```libimobiledevice``` family and ```ifuse``` package installed. When I connect my iPhone to Linux via USB cable I get the prompt to allow access. When I confirm, I can access the ```DCIM``` folder on gnome file explorer. However no other folders appear. Also I can only move photos and vi...
I have the
family and
package installed. When I connect my iPhone to Linux via USB cable I get the prompt to allow access. When I confirm, I can access the
folder on gnome file explorer. However no other folders appear. Also I can only move photos and videos from the phone to my desktop and not the other way around. When I try to do that, I get an error:
There was an error copying the file into gphoto2://-Apple_Inc._iPh...123456789AB/DCIM/202304__.
Error writing file: -108: No such file or directory
How can I access documents other than photos and videos? How can I inject a file into iphone from linux?
zpc5679 (111 rep)
Apr 4, 2023, 07:12 AM • Last activity: May 6, 2025, 02:36 PM
0 votes
0 answers
26 views
Why is set -e also ignored for functions called via command substitution
I've seen [questions][1] [about][2] this topic, but they talk about constructs like `if` or `||`. I don't understand why the same behavior seem to happen for substitution (`$()`)? ``` $ my_function() { echo "the following command could fail:"; false; echo "this is after the command that fails"; } $...
I've seen questions about this topic, but they talk about constructs like if or ||. I don't understand why the same behavior seem to happen for substitution ($())?
$ my_function() {     echo "the following command could fail:";     false;     echo "this is after the command that fails"; }
$ (set -ex; var=$(my_function); echo "$var" )
++ my_function
++ echo 'the following command could fail:'
++ false
++ echo 'this is after the command that fails'
+ var='the following command could fail:
this is after the command that fails'
+ echo 'the following command could fail:
this is after the command that fails'
the following command could fail:
this is after the command that fails
vs
$ my_function() { set -e;     echo "the following command could fail:";     false;     echo "this is after the command that fails"; }
$ (set -ex; var=$(my_function); echo "$var" )
++ my_function
++ set -e
++ echo 'the following command could fail:'
++ false
+ var='the following command could fail:'
errexit seems to behave as expected for simple commands:
$ (set -ex; var=$(false); echo "$var" )
++ false
+ var=
If I use read instead I get the expected behaviour:
$ my_function() {     echo "the following command could fail:";     false;     echo "this is after the command that fails"; }
$ (set -exo pipefail; my_function | read var; echo "$var" )
+ my_function
+ echo 'the following command could fail:'
+ read var
+ false
Jakub Bochenski (325 rep)
Apr 29, 2025, 03:30 PM • Last activity: Apr 29, 2025, 03:36 PM
0 votes
1 answers
5147 views
Grub rescue error (insmod normal)
[![enter image description here][1]][1] I was trying to make it normal from grub rescue error. But, msdos7 is returning that filesystem is ext2. When I write insmod normal I get "invalid file name 'hd0,msdos7/i386-pc/normal.mod" How can I fix it? I have bootable USB . that's arch Linux. Even, I trie...
enter image description here I was trying to make it normal from grub rescue error. But, msdos7 is returning that filesystem is ext2. When I write insmod normal I get "invalid file name 'hd0,msdos7/i386-pc/normal.mod" How can I fix it? I have bootable USB . that's arch Linux. Even, I tried by bootable USB also. When I reboot my laptop that(grub Loader) don't show anymore(like it had erased automatically when rebooting). I was following the answer https://askubuntu.com/a/462995 When I tried to search search.file ... I got an error unknown command 'search.file'. enter image description here root@mint:~# fdisk -l Disk /dev/loop0: 1.8 GiB, 1912557568 bytes, 3735464 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/sda: 298.9 GiB, 320072933376 bytes, 625142448 sectors Disk model: Hitachi HTS72323 Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xcdead0a2 Device Boot Start End Sectors Size Id Type /dev/sda1 * 1026048 272532369 271506322 129.5G 7 HPFS/NTFS/exFAT /dev/sda2 272533504 273694719 1161216 567M 27 Hidden NTFS WinRE /dev/sda3 273696768 274747391 1050624 513M b W95 FAT32 /dev/sda4 274747392 625142447 350395056 167.1G 5 Extended /dev/sda5 274749440 275726335 976896 477M ef EFI (FAT-12/16/32) /dev/sda6 275728384 277682175 1953792 954M 82 Linux swap / Solaris /dev/sda7 277684224 625142447 347458224 165.7G 83 Linux This is how I installed grubloader but, I am getting the grub error although. /dev/sda7 is arch Linux. And, /dev/sda1 is windows. I had Kali earlier. I had deleted partition/volume of kali,swap and grub from windows manager. enter image description here I noticed that type /dev/sda7 is ext2. But, I remember that I formatted it to ext4. Now, I have Linux Mint bootable USB. root@mint:~# mount /dev/sda5 /mnt mount: /mnt: /dev/sda5 already mounted on /mnt. root@mint:~# grub-install /dev/sda5 Installing for i386-pc platform. grub-install: error: failed to get canonical path of `/cow'. [![enter image description here]] I was following [the video](https://youtu.be/biGNIMIRgNU?t=303) . I notice that he set flags to bios_grub. But, I don't have bios_grub. What to do now?
user467213
Apr 19, 2021, 01:29 PM • Last activity: Apr 6, 2025, 10:04 AM
0 votes
1 answers
123 views
How can I set a bash script to wait for user input (not exit) on error?
I know that `set -e` tells bash to exit the script on error. The problem is that I have to address the error, then delete all previous steps from the script while maintaining any variables before executing it again to continue. Is there a way to have the script simply wait for user input `read -p "C...
I know that set -e tells bash to exit the script on error. The problem is that I have to address the error, then delete all previous steps from the script while maintaining any variables before executing it again to continue. Is there a way to have the script simply wait for user input read -p "Continue? " on error? If not, is there anything similar? I want the script to stop on error, then continue again when I'm ready.
user2013318 (11 rep)
Mar 6, 2025, 01:30 PM • Last activity: Mar 6, 2025, 03:59 PM
1 votes
1 answers
63 views
Help figuring out how to handle errors in "mongodump" script
I have a simple bash script that's supposed to create a dump file from a database ``` docker exec -i container sh -c "mongodump --archive" > \ ~/dumps/db-$(date + "%d%m%Y").dump 2> \ ~/logs/dumps/db-$(date + "%d%m%Y").log \ ``` I've been asked to ensure the script will handle any errors, so I attemp...
I have a simple bash script that's supposed to create a dump file from a database
docker exec -i container sh -c "mongodump --archive" > \
    ~/dumps/db-$(date + "%d%m%Y").dump 2> \
    ~/logs/dumps/db-$(date + "%d%m%Y").log \
I've been asked to ensure the script will handle any errors, so I attempted adding the following to the script.
docker exec -i container sh -c "mongodump --archive" > \
    ~/dumps/db-$(date + "%d%m%Y").dump 2> \
    ~/logs/dumps/db-$(date + "%d%m%Y").log \

exit_status=$?
if [ exit_status -ne 0 ]; then
    echo "An error occured while running mongodump. Exit Status: $exit_status"
fi
The above was my attempt. If the exit status is anything but 0, send an echo message with the actual exit code. The script successfully creates a dump file, however I receive the following error:
[: exit_status: integer expression expected
My assumption is that because of my log redirection, the command itself doesn't actually report a exit status on completion. But I'm not so sure. I'm still learning the ropes of Bash scripting, so any advice is appreciated.
Ambre (111 rep)
Jan 21, 2025, 03:46 PM • Last activity: Jan 21, 2025, 05:40 PM
1 votes
2 answers
346 views
Remove exact line from file if present, leave the rest of lines; error-handling - how to go about it
I am not exactly sure how text processing should be done in a good way, so let me ask. I have this file: `~/.config/mpv/input.conf` containing possibly other options as well as `v disable`. If I want to remove that line from the file, I suppose I could do: ```lang-sh grep -v -q -F 'v disable' input....
I am not exactly sure how text processing should be done in a good way, so let me ask. I have this file: ~/.config/mpv/input.conf containing possibly other options as well as v disable. If I want to remove that line from the file, I suppose I could do:
-sh
grep -v -q -F 'v disable' input.conf; echo $?
1
Where - if the file contains nothing else like now, it would return 1 (man page says 1 - "No lines were selected."), which troubles me as I cannot run a simple if-statement. So I would have to store $? after the command and then check if it is greater than 1 for error. Also, it is unclear to me, if replacing the file in-place is a good idea:
-sh
grep ... input.conf > input.conf
--- If there is some other way, let me know. Also if portions of my suggestions are correct, please let me know. Thanks, and cheers. --- EDIT1: Desired behavior is to toggle between the state where there is this line (done with simple >> addition after a check if it is there, and is not (remove it, thus this question). EDIT2: The accepted solution must be POSIX-compliant. No _bashisms_ or non-POSIX tools. You can, however, include non-POSIX solutions which might be useful for other people. In any case, thanks.
Vlastimil Burián (30505 rep)
Jun 22, 2023, 09:24 AM • Last activity: Jan 11, 2025, 09:48 AM
1 votes
0 answers
71 views
What's the logic in exiting early on failure in blocks and subshells in Bash?
In Bash blocks {} and subshells () the exit early doesn't work if there is an OR condition following it. Take for example ``` set -e { echo a; false; echo b; } || echo c ``` prints ``` a b ``` and ``` set -e { echo a; false; echo b; false;} || echo c ``` prints ``` a b c ``` It seems to take the las...
In Bash blocks {} and subshells () the exit early doesn't work if there is an OR condition following it. Take for example
set -e
{ echo a; false; echo b; } || echo c
prints
a
b
and
set -e
{ echo a; false; echo b; false;} || echo c
prints
a
b
c
It seems to take the last executed command's exit code only. While this makes sense, given a semicolon instead of && is used, I'd expect the set -e to still make it exit on the first false and execute the error handling echo c code. Using && instead of ; does make it work, but that makes it messy when having multiple line blocks. Adding in set -e at the start of the block/subshell also has no effect. The reason this confuses me is because
set -e
{ echo a; false; echo b; }
prints
a
which means the exit-on-failure works when there's no || code following it. So I'd expect this to be the case with || code following it, executing it after the first failure in the block. Is there no way to achieve that without appending && after each line in the block?
QuickishFM (141 rep)
Dec 20, 2024, 01:34 PM • Last activity: Dec 20, 2024, 02:06 PM
132 votes
9 answers
100138 views
Preventing grep from causing premature termination of "bash -e" script
This script does not output `after`: #!/bin/bash -e echo "before" echo "anything" | grep e # it would if I searched for 'y' instead echo "after" exit I could solve this by removing the `-e` option on the shebang line, but I wish to keep it so my script stops if there is an error. I do not consider `...
This script does not output after: #!/bin/bash -e echo "before" echo "anything" | grep e # it would if I searched for 'y' instead echo "after" exit I could solve this by removing the -e option on the shebang line, but I wish to keep it so my script stops if there is an error. I do not consider grep finding no match as an error. How may I prevent it from exiting so abruptly?
iago-lito (2931 rep)
Dec 15, 2016, 04:23 PM • Last activity: Dec 5, 2024, 05:12 PM
31 votes
6 answers
18597 views
How can I suppress output only if the command succeeds?
I would like to simplify the output of a script by suppressing the output of secondary commands that are usually successful. However, using `-q` on them hides the output when they occasionally fail, so I have no way of understanding the error. Additionally, these commands log their output on `stderr...
I would like to simplify the output of a script by suppressing the output of secondary commands that are usually successful. However, using -q on them hides the output when they occasionally fail, so I have no way of understanding the error. Additionally, these commands log their output on stderr. Is there a way to suppress a command's output **only if it succeeds**? For example (but not limited to) something like this: mycommand | fingerscrossed If all goes well, fingerscrossed catches the output and discards it. Else it echoes it to the standard or error output (whatever).
Matthieu Napoli (1202 rep)
Jan 18, 2016, 05:04 PM • Last activity: Sep 7, 2024, 05:33 AM
1 votes
1 answers
1052 views
Linux kernel build fails with sed: can't read modules.order: No such file or directory
I am trying to build Linux Kernel for the first time and I am facing below issue while trying to _make modules_install_ sed: can't read modules.order: No such file or directory make: *** [Makefile:1483: __modinst_pre] Error 2 So I went and reran _make -j4_ and checked it's exit code suing echo $? it...
I am trying to build Linux Kernel for the first time and I am facing below issue while trying to _make modules_install_ sed: can't read modules.order: No such file or directory make: *** [Makefile:1483: __modinst_pre] Error 2 So I went and reran _make -j4_ and checked it's exit code suing echo $? it returns exit code 2 dejani@dejani-linux:~/Documents/linux-6.0.7$ make -j4 DESCEND objtool DESCEND bpf/resolve_btfids CALL scripts/atomic/check-atomics.sh CALL scripts/checksyscalls.sh make: *** No rule to make target 'debian/canonical-certs.pem', needed by 'certs/x509_certificate_list'. Stop. make: *** Waiting for unfinished jobs.... make: *** [Makefile:1852: certs] Error 2 make: *** Waiting for unfinished jobs.... CHK include/generated/compile.h CHK kernel/kheaders_data.tar.xz dejani@dejani-linux:~/Documents/linux-6.0.7$ echo $? 2 Can anyone help me out here? How do I get it to print errors/warnings/stack traces?
Devansh Jani (11 rep)
Sep 11, 2023, 02:51 PM • Last activity: Aug 30, 2024, 05:09 AM
2 votes
2 answers
2736 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 to cause that error to actually be generated.
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 to cause that error to actually be generated.
LINUX G33NYUS (776 rep)
Mar 13, 2017, 08:54 PM • Last activity: Jul 17, 2024, 04:59 PM
0 votes
2 answers
476 views
How to execute command if previous command fails with return code 0
I have a script which logs in to a server. Regardless of the success (i.e. whether the password is valid or not) the script will exit with return code 0, and the text: Error login failed. I'd like it to retry login if this happens by running another command, but because of the return code I can't. I...
I have a script which logs in to a server. Regardless of the success (i.e. whether the password is valid or not) the script will exit with return code 0, and the text: Error login failed. I'd like it to retry login if this happens by running another command, but because of the return code I can't. If I pipe the output to grep for 'Error' so I can execute a command based on that then the login dialog doesn't show up in the terminal. Is there anyway around this? Pseudo code as this is for work:
loginCmd && echo "$?"
username:
password:

Error login failed. 
0
### Update I tried using an idea from a commentator, but I can't capture the text with 'Error' as that line occurs after the command completes... Here's what it actually looks like, with incorrect password:
agent registration
username: xyz
password:

Error login failed.
I tried this:
result=$(loginCmd | tee /dev/tty)

grep -q 'Error' <<< "$result" && 
    loginCmd
The error string outputs after the command completes, so result doesn't capture it:
result=agent registration
So I guess there is no way to capture this string?
Error login failed.
Any ideas? Ideally on login failure the script would return 1, or have some sort of retry mechanism, but it doesn't and I can't change that, it's a company script and this only affects the terminal, not the GUI which is what customers use.
Nickotine (554 rep)
Jul 8, 2024, 07:41 PM • Last activity: Jul 11, 2024, 04:43 PM
0 votes
2 answers
238 views
tar: ./.tar.gz: file changed as we read it | "Flagged" files are unrelated to the file tar is supposed to operate on
I am trying to use `tar` to recursively compress all files with the `.lammpstrj` extension within the directory tree starting at the directory whose path is stored in the variable `home`. `home` contains the script containing my `tar` commands and 57 subdirectories, each containing a pair of sub-sub...
I am trying to use tar to recursively compress all files with the .lammpstrj extension within the directory tree starting at the directory whose path is stored in the variable home. home contains the script containing my tar commands and 57 subdirectories, each containing a pair of sub-subdirectories named Soft_Pushoff and Equilibrium_NVT. Each Soft_Pushoff or Equilibrium_NVT directory contains one .lammpstrj file. The loop I am using to get this task done is: for index in $(seq 1 57) do cd $home/$index/Soft_Pushoff/ file=find ./ -mindepth 1 -maxdepth 1 -name "*.lammpstrj" -print tar cvf - ./$file | gzip -9 - > $file.tar.gz cd $home/$index/Equilibration_NVT/ file=find ./ -mindepth 1 -maxdepth 1 -name "*.lammpstrj" -print tar cvf - ./$file | gzip -9 - > $file.tar.gz done As it sweeps one of the 57 subdirectories of home, this section of the code usually prints: ././equilibration_nvt.lammpstrj ././soft_pushoff.lammpstrj to the terminal. However, in 3 different instances, this is what this section of the code prints out: ././equilibration_nvt.lammpstrj ././soft_pushoff.lammpstrj ./ ./time.txt ./soft_pushoff.restart.10000 ./equilibration_nvt.lmp ./.tar.gz tar: ./.tar.gz: file changed as we read it ./equilibration_nvt_pitzer.sh ./eps.txt ././soft_pushoff.lammpstrj ././equilibration_nvt.lammpstrj None of the files "flagged" by tar is supposed to be operated on by the tar commands I am using, so I am confused as to why they are listed alongside the warning message tar: ./.tar.gz: file changed as we read it? Also, none of these files is actually changing as tar is operating on the .lammpstrj files. What could explain this warning message and, most importantly, can I trust that none of the .lammpstrj.tar.gz files written by my tar commands is corrupt, especially the ones associated with this warning message? If this is relevant, my script is being run on a remote server. The .lammpstrj files I am trying to compress are up to 15.2 Gb in size. It takes about 2.5 days for my script to run on this remote server.
Felipe Evaristo (37 rep)
Jun 12, 2024, 04:35 PM • Last activity: Jun 14, 2024, 08:11 PM
1 votes
0 answers
77 views
bash: is it possible to make `errexit` work inside conditionals?
Consider the following script: ``` #!/bin/bash set -o errexit -o xtrace qux() { false echo QUX } quux() { qux ||: echo QUUX } quux ``` Running this script produces: ``` + quux + qux + false + echo QUX QUX + echo QUUX QUUX ``` In other words, not only does `quux` ignore the return code of `qux`, it a...
Consider the following script:
#!/bin/bash

set -o errexit -o xtrace

qux() {
        false
        echo QUX
}

quux() {
        qux ||:
        echo QUUX
}

quux
Running this script produces:
+ quux
+ qux
+ false
+ echo QUX
QUX
+ echo QUUX
QUUX
In other words, not only does quux ignore the return code of qux, it also causes qux discard non-zero error codes within itself, a somewhat counterintuitive behavior. Until now, I have been writing scripts under the assumption that set -o errexit terminates the shell whenever a program or function returns a non-zero code. However, I discovered that errexit doesn't work inside conditionals. Instead, it functions like a global switch that conditionals turn off until they are evaluated. Is it possible to make set -o errexit work inside conditionals? Is there a shell that supports it?
Azat Khabibulin (133 rep)
May 29, 2024, 04:20 PM • Last activity: May 29, 2024, 08:14 PM
1 votes
1 answers
1430 views
Permission denied: Linux KVM Share
When I tried to start the VM I get the following Error (Note, the host is a OpenSUSE Leap 15.3): ``` Traceback (most recent call last): File "/usr/share/virt-manager/virtManager/asyncjob.py", line 75, in cb_wrapper callback(asyncjob, *args, **kwargs) File "/usr/share/virt-manager/virtManager/asyncjo...
When I tried to start the VM I get the following Error (Note, the host is a OpenSUSE Leap 15.3):
Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 75, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 111, in tmpcb
    callback(*args, **kwargs)
  File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 66, in newfn
    ret = fn(self, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/object/domain.py", line 1281, in startup
    self._backend.create()
  File "/usr/lib64/python3.6/site-packages/libvirt.py", line 1234, in create
    if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirt.libvirtError: Internet Error: qemu unexpectedly closed the monitor: 2022-04-13T10:23:46.817809Z qemu-system-x86_64: -device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=/home/turbine,bus=pci.7,addr=0x0: cannot initialize fsdev 'fsdev-fs0': failed to open '/home/user/shared': Permission denied
My shared folder configuration gives me:
Delfin (150 rep)
Apr 13, 2022, 10:30 AM • Last activity: Feb 21, 2024, 08:53 PM
Showing page 1 of 20 total questions