Questions tagged [exec]

The exec() family of functions replaces the current process image with a new process image, retaining the pid and pipes of the old process. This tag is also used for the shell built-in which can be used to replace the current shell with a program or various redirection-related stuff.

Filter by
Sorted by
Tagged with
0 votes
0 answers
46 views

exec terminate command by the space in single quotes

I have a simple bash script goes like #!/bin/bash set -e SPARK_CONF="--master ... \ ... --conf spark.driver.extraJavaOptions='-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps' \ --conf ....&...
user avatar
0 votes
0 answers
24 views

pass output as grep pattern [duplicate]

I wish to pass each line of a file as a grep pattern to be searched in data.txt file. Thus, i need cat allsearchstrings.txt | grep <should be lines of allsearchstrings.txt> data.txt cat ...
user avatar
  • 307
0 votes
1 answer
95 views

`exec env` vs `env`

Both exec and env don't fork, see the following example: docker run --rm -it ubuntu:18.04 sh -c 'exec sleep 1 & ps -Ho pid,ppid,cmd' PID PPID CMD 1 0 sh -c exec sleep 1 & ps -Ho ...
user avatar
  • 1,059
2 votes
1 answer
73 views

Output to variable or file using (find with -exec and shred)

I have a find command that I exec to shred and it works great; however, I need to capture the output of this and pass to a variable or a file. I have tried so many iterations of the below commands, ...
user avatar
0 votes
2 answers
1k views

How to launch application with rofi using i3wm's exec?

I had this issue and now I know how to solve it. I need to launch applications with i3wm's exec command. ButI use rofi as launchmenu and I have no idea how to make it lauch applications with i3wm's ...
user avatar
0 votes
0 answers
105 views

Delete all files in directories tomcat_*/temp on each application restart

We do have an operation script to stop, restart and start tomcat services. I am asked to make changes in the operation script so when starting tomcat with operation_script.sh, All files in directories ...
user avatar
11 votes
2 answers
1k views

What does `exec 6>&1` or similar do?

I'm migrating some software from Unix to Linux. I have the following script; it is a trigger of a file transfer. What do the exec commands do? Will they work also on Linux? #!/bin/bash flog=/mypath/...
user avatar
  • 267
1 vote
0 answers
275 views

How is i3 window manager started by startx in Ubuntu (so that I can configure what display it appears on)?

I want to set up i3 automatically start on a specific one of my three screens (all connected to one Nvidia card). This has proved more difficult than expected. My first choice was to just set that ...
user avatar
4 votes
1 answer
187 views

How to increment COUNTER in -exec script?

Context: zsh Catalina MacOS: The executable script BatesStamp engages imagemagick to stamp a number to a jpg file: # BatesStamp: OVERWRITES and stamps ONE file with COUNTER (upper left corner) # ...
user avatar
  • 1,114
0 votes
2 answers
60 views

exec vscode not redirecting output to /dev/null

I have the following bash script: exec '/mnt/c/Users/WindowsUserName/AppData/Local/Programs/Microsoft VS Code/Code.exe' $@ &>/dev/null & When I run the script I get ➜ ~ ./code foo.js ➜ ~ ...
user avatar
0 votes
0 answers
78 views

Interrupting rsync crashes a container

Consider the following script (/tmp/a.sh). It prepares an environment to run rsync: #!/bin/sh -eu docker run --rm -it \ -v /:/host \ alpine sh -c ' apk add rsync shadow procps ...
user avatar
  • 2,913
2 votes
1 answer
198 views

How does exec > work in AWS EC2 user data?

I was writing a Terraform module for AWS EC2 that involved executing a bash in the user data section. While I was developing I had an issue in the script I wrote but neither AWS nor Terraform provided ...
user avatar
0 votes
2 answers
1k views

exec command not found error in Linux

below commands are giving output and exiting the terminal exec sleep 60 exec pwd below commands throws error. please advise on the exec behaviour $ exec test1.sh -bash: exec: test1.sh: not found $ ...
user avatar
  • 11
0 votes
3 answers
144 views

How to pass grep result to a varible so i can use it with exec tar command?

I am trying to compress all folder in dir based on some regex so I used grep to filter out the output now i need to use tar and folder name. For example I want to .tar.gz each top level directory to ...
user avatar
  • 101
0 votes
1 answer
113 views

php exec/shell_exec behavior CLI vs CGI

I am trying to use php to run some system commands and am getting a behaviour that I don't fully understand. If the php script is run from the command line I get the results I expect. But running it ...
user avatar
0 votes
0 answers
80 views

Exec Not Updating Values from Certain Bash Functions and Variables When Prepending Script Output

I am logging messages in Bash where I add some useful information to the log message to help provide context. However, in the final output most of my variables and functions appear to only use their ...
user avatar
-1 votes
1 answer
153 views

Output of this command Linux [closed]

Please do anyone has an idea about the output of this command , I have googled a lot about it but I can't find anything useful find . -type f -exec grep -H PATH {} \; Thanks in advance
user avatar
0 votes
0 answers
42 views

OpenBSD 6.9 - ENOMEM error on execve (execvp)

I've compiled a program on OpenBSD 6.9 and when I execute the program, I get an enomem error related specifically to execvp which the man pages say is a font-end for execve. The execve man page ...
user avatar
0 votes
1 answer
107 views

process hangs after redirecting stderr using exec

I want to redirect stdout and stderr to 2 pipes one for each to create the pipes I used: mkfifo -m 0666 /var/run/log_stdout.pipe mkfifo -m 0666 /var/run/log_stderr.pipe and it works fine, but ...
user avatar
  • 1
0 votes
1 answer
169 views

ip netns exec cannot start ONLY mate-terminal and gnome-terminal?

I am using the newns script from here: https://superuser.com/questions/983727/route-only-specific-traffic-through-vpn ... except on this system: $ mate-about -v MATE Desktop Environment 1.24.0 $ cat /...
user avatar
  • 6,246
7 votes
2 answers
1k views

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 ...
user avatar
0 votes
2 answers
49 views

How to delete ALL directories but NOT files from another location in execv? [closed]

Let's say I'm at the home directory and I have a directory called 'Apple' that has 2 directories (let's say I don't know their names) with contents in them and several files. I open my terminal in ...
user avatar
  • 3
0 votes
1 answer
396 views

Why is 'ls' being created by execve() call and not fork()

From my understanding whenever you type a command such as 'ls' in your shell, the parent process which is my shell duplicates itself using fork() system call and then uses the exec() system call to ...
user avatar
  • 103
2 votes
1 answer
199 views

How can I redirect all output of a script to a file and replace passwords?

I'm running a ksh script on AIX 7.2. In debug mode I want to redirect all the script does to a brkpt-file. The script also makes logins to another application and therefore uses a password (let's say &...
user avatar
  • 23
0 votes
1 answer
803 views

Execute an shell script with sudo inside from php

I want to execute a command line command as root from a php file. In my case I want to view the crontab file in my php page. Running the sudo command in php is not recommended and on my raspberry pi ...
user avatar
1 vote
1 answer
255 views

What does `exec` with no arguments do?

exec with no arguments returns success and apparently does nothing. Why?
user avatar
3 votes
2 answers
143 views

Count lines in csv files nested in subdir using find exec

I'd like to run two piped commands on the results of find on some nested csv files, but I miserably fail. Here is the idea: $ find ./tmp/*/ -name '*.csv' -exec tail -n +2 {} | wc -l \; in order not ...
user avatar
  • 213
0 votes
1 answer
106 views

find & copy command is not copying same number of files

I'm trying to use find & copy on some files but the problem is if i only run find command and check wc it shows some result, after copying these files to some other directories it shows some other ...
user avatar
  • 11
0 votes
0 answers
74 views

Writing output of ls using exec to a variable [duplicate]

I am trying to write the output of exec ls to a variable. I am new to bash so probably overlooking something simple. The aim is to check a mount within a docker container and if it comes back with a ...
user avatar
6 votes
3 answers
3k views

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, ...
user avatar
  • 1,997
-2 votes
1 answer
408 views

Does execve() make a child unrelated to its parent?

When a process fork() a child, the two processes are related. The child inherits a lot of things from the parent, including some IPC objects such as pipes and anonymous memory mappings. If the child ...
user avatar
  • 90.7k
2 votes
1 answer
121 views

Why does `exec init` work in podman but not buildah with the same options?

How are these two commands different? Both of them launch a shell as pid 1 and make the same mounts and volumes, buildah run --tty --mount type=tmpfs,destination=/run -v /sys/fs/cgroup:/sys/fs/cgroup:...
user avatar
  • 22.9k
1 vote
1 answer
101 views

Issues with bash script containing exigrep command when invoked from PHP webpage

I have a bash script to extract information from exim_mainlog. When the bash script is run from a putty command line (logged in as root), the extracted data is properly written to an output file. ...
user avatar
  • 11
2 votes
1 answer
528 views

Hot replacing a PID 1 process inside a container without crashing

As you know a OCI container (more commonly known as Docker container) terminates once its entrypoint process (a.k.a. PID1 inside the container's namespace) exits. However, I'm curious if there's a way ...
user avatar
1 vote
2 answers
508 views

FIFO-based semaphore explanation

I am trying to work on some parallelization of many processes (task send/to be executed on many (let's say hundreds) nodes). I came across this solution: https://unix.stackexchange.com/a/216475 # ...
user avatar
-3 votes
1 answer
54 views

Basic command problems

I tried to figure out what is the difference those commands (for a school project), but for me its chrashed or running for more than 10min~ So, the sample: sudo find / -type f -exec file ’{}’ ; | ...
user avatar
1 vote
2 answers
58 views

How to recursively shift `<user_id>`:`<group_id>` by a specific value using `xargs` or `exec`

I'm trying to recursively shift <user_id>:<group_id> by a specific value using xargs or exec. I'm having difficulty with passing output from find to variable with stat function. I'm ...
user avatar
-2 votes
1 answer
903 views

Exec format error

I know this gets thrown around a lot, but it just didn't make sense to me. So, I compiled C code using the installed gcc compiler but it just would execute. Many other posts said that it was probably ...
user avatar
1 vote
1 answer
182 views

script hangs due to `exec` on AiX servers with ksh shell

Below script runs fine on all Servers in my infrastructure. However, I recently discovered that it fails to complete execution and simply hangs on Aix servers with ksh shell. cat myscript.sh export ...
user avatar
  • 307
0 votes
1 answer
364 views

Trouble with the command "-exec ls -l {} "

I was working on a lab and was having trouble with the function of part of a command we are supposed to learn. Here it is: find . -name "*.txt" -exec ls -l {} \; I have determined that the ...
user avatar
0 votes
1 answer
138 views

How did Linux load this exe compiled with C#? [duplicate]

I just discovered something really surprising. I can compile a simple C# hello world on my windows computer using csc (from Visual Studio), copy the resulting exe file to my Linux computer, and ...
user avatar
  • 113
1 vote
0 answers
47 views

Prompt is not shown after running a script with an "exec" command redirecting stdout and stderr [duplicate]

An example script is shown below. The meaning of the syntax - exec > >(tee -a "$file" "$sec_file") 2>&1 , is to print to the console the stdout and sdterr , and also ...
user avatar
  • 11.1k
1 vote
2 answers
113 views

perl cannot `exec` to binary

In my fresh installation of Debin, perl intepreter is installed by default (in other words, I have no other perl packages yet). However, trying this: $ls a.cpp b.cpp $ perl -e 'system "g++ -o a....
user avatar
2 votes
1 answer
2k views

Identical execve causes "Permission denied" for one program but not another

Permission denied shows up when I try to open some attachment in Thunderbird. Yet, it doesn't look as a Thunderbird bug, because when I strace the process I see it issues the correct call. Yet it ...
user avatar
  • 129
1 vote
2 answers
539 views

Output tee to stdout while writing to a FD using here-strings

I am trying to output tee while writing to a custom file descriptor. Example: exec 4>"/tmp/testfile.txt"; # open FD 4 tee -a >&4 <<< "Output this to stdout" # ...
user avatar
  • 113
3 votes
3 answers
178 views

Move files that have a value above a threshold in any row of a specific column

I have a large number of files in a particular folder. I would like to move these files to a subfolder ONLY IF they have at least 1 value above 0.5 in any row of column 4. In a separate command I'd ...
user avatar
  • 37
0 votes
0 answers
66 views

Mount does not work in script when run by php

So I have a script that's placed in my apache2 html folder and should be executed by an http post. The script requires root (I know that's not safe at all, ignore that please), so I set the user www-...
user avatar
0 votes
1 answer
306 views

exec command won't accept xargs, hangs on command input

I'm not super familiar with exec. I was running through some tests and examples. I wanted to pass a command written in a file to it. I'm expecting that command to be run with exec just as if it were ...
user avatar
3 votes
1 answer
438 views

What is this script doing?

#!/bin/bash echo 123456789 > out.txt exec 3<> out.txt read -n 4 <&3 echo -n 5 >&3 exec 3>&- Was asked the content of out.txt at the end of script, in an interview ...
user avatar
  • 168
0 votes
1 answer
108 views

Where is do_execve located?

In Linux, there is a function called do_execve in fs/exec.c. Where is the object file of the function located after Linux has been compiled? Where is the .ko file that contains it?
user avatar

1
2 3 4 5 6