exec

How to stop redirection via exec

How to stop redirection via exec I want to redirect some output of a script to a file. REDIRECT_FILE="foo.txt" echo to console # starting redirect exec > $REDIRECT_FILE echo to file echo … echo … # stop redirect exec >&- echo end of script "end of script" should be written to stdout. But instead there …

Total answers: 1

How to display file and folder properties from search

How to display file and folder properties from search I thought this would be easy and there are a lot of somewhat close threads on the internet, but nothing quite right. I want to use fd (simple find command) to display just file name and file size (preferably in mb, or formatted more readable than …

Total answers: 1

Why 'helix-23.03-aarch64.AppImage' [in debian on x86_64 in Macbook Pro] is giving 'Exec format error'?

Why 'helix-23.03-aarch64.AppImage' [in debian on x86_64 in Macbook Pro] is giving 'Exec format error'? It is on debian on x86_64 me@debian:~/bin$ chmod a+x helix-23.03-aarch64.AppImage me@debian:~/bin$ ./helix-23.03-aarch64.AppImage /tmp/.mount_helix-RyzFyw/AppRun: 4: exec: /tmp/.mount_helix-RyzFyw/usr/bin/hx: Exec format error Asked By: tom_kp || Source aarch64 AKA ARM64 like the name suggests is the 64-bit extension of the ARM architecture family. If …

Total answers: 1

Redirecting stderr to temporary fd in a Bash script

Redirecting stderr to temporary fd in a Bash script I see that many questions have been asked and answered on SE about redirections in Bash using exec, but none seem to answer my question. What I’m trying to accomplish is redirect all output to stderr in a script to a temporary fd and restitute it …

Total answers: 2

Need to capture exit code of pylint command using find in Github actions

Need to capture exit code of pylint command using find in Github actions I am trying to implement a python linter using pylint. But I am getting the score of each python file and also displaying the suggestion to improve the score but I am also looking to terminate the GitHub action job if my …

Total answers: 1

What happens to the file structs of processes after execve

What happens to the file structs of processes after execve If I understand the man pages correctly, the fd table of a process that forks and execves are copied to the the child process and survive the execve. On the other hand, any other memory mapping is destroyed after the execve. Therefor I expexted file …

Total answers: 2

Why does exec print its output after the program exits?

Why does exec print its output after the program exits? I’m writing a program to pipe one command to another. Inputs will be from the command line: $ ./a.out ls ‘|’ wc c2 PID 6804 c1 PID 6803 PARENT PID 6802 $ 2 2 17 Why does the output print after the prompt returns. Is …

Total answers: 2

What does `exec` with no arguments do?

What does `exec` with no arguments do? exec with no arguments returns success and apparently does nothing. Why? Asked By: Carla is my name || Source The way Bash’s manual puts it, the syntax of exec is exec [-cl] [-a name] [command [arguments]] and If command is supplied, it replaces the shell without creating a …

Total answers: 2

Find -exec dry run?

Find -exec dry run? Is there a way to see what the result of a find . -exec somecommand {} ; would be with substitutions, without actually running the commands? Like a dry run (or test run or print)? For example, suppose I have the following file structure: /a/1.txt /a/2.txt /a/b/3.txt Is there a way …

Total answers: 3

Does POSIX guarantee the paths to any standard utilities?

Does POSIX guarantee the paths to any standard utilities? From C, what’s the easiest way to run a standard utility (e.g., ps) and no other? Does POSIX guarantee that, for example, a standard ps is in /bin/ps or should I reset the PATH environment variable to what I get with confstr(_CS_PATH, pathbuf, n); and then …

Total answers: 2

/bin/sh: 0: Can't open sh

/bin/sh: 0: Can't open sh I’m trying to run a simple C program. #include <stdio.h> #include <unistd.h> extern char** environ; int main(){ // execl(“/bin/sh”,”sh”,”-c”,”/bin/ls -l”,(char *) NULL); char* argv[] = {“/bin/sh”,”sh”,”-c”,”/bin/ls”, (char*) NULL}; execve(argv[0], argv, environ); return 0; } The commented out execl runs fine. But when I try to do the same with execve, …

Total answers: 1

Echo to file descriptor overwrites the file?

Echo to file descriptor overwrites the file? I am having trouble understanding what is happening when I try to write to a file descriptor? It appears to be overwriting the original contents? Is this expected behaviour? I have replicated this in the example below: $ echo “The quick brown fox …” > example.txt $ echo …

Total answers: 2

Using exec 3> to keep a named pipe open

Using exec 3> to keep a named pipe open The process reading from a named pipe will normally terminate when the process writing to the pipe finishes writing (sends an EOF). In certain situations you may have different processes writing intermittently to the pipe, and want a single process to continuously read from the pipe. …

Total answers: 1

Does the Linux kernel support a PARTIAL exec

Does the Linux kernel support a PARTIAL exec I was looking at another question (https://stackoverflow.com/q/47845/537980), and saw an answer, about how much set up this other OS had to do, for every Process Create. I got wondering. Would it be possible to do the setup (once, then fork), then do a partial exec to load …

Total answers: 2

Capture exit code of exit command

Capture exit code of exit command I have this in a bash script: exit 3; exit_code=”$?” if [[ “$exit_code” != “0” ]]; then echo -e “${r2g_magenta}Your r2g process is exiting with code $exit_code.${r2g_no_color}”; exit “$exit_code”; fi It looks like it will exit right after the exit command, which makes sense. I was wondering is there …

Total answers: 5

Why does ` exec 2>somefile` hang?

Why does ` exec 2>somefile` hang? Why does exec >somefile return immediately, while exec 2>somefile doesn’t and hang on indefinitely? Thanks. Asked By: Tim || Source It doesn’t hang. If you’re running interactively, and you look inside somefile, you’ll see your prompt. STDERR is where bash writes the prompt to. Answered By: phemmer

Total answers: 1

What logic does the command "exec tail -n +3 $0" from grub2 config have?

What logic does the command "exec tail -n +3 $0" from grub2 config have? Creating custom menu entry, got stuck on this command: exec tail -n +3 $0 Tried it in terminal, got weird result, cannot understand, what this command exactly does and why grub needs it. Could you explain, please? Asked By: Imajou || …

Total answers: 2