The exec() family of functions replaces the current process image with a new process image, retaining the pid and pipes of the old process.

learn more… | top users | synonyms

2
votes
0answers
32 views

Detach from tmux and rotate to ssh without dropping exec?

I've been using tmux launched by default as part of my shell at all times for some time now and find it very convenient. At the same time ssh'ing from inside tmux to another system is not ideal ...
3
votes
2answers
113 views

umask XXX (permission bits) to give execute permission to files

Because files created by default having permission of 666 and umask (in permission bits form) subtract bit-wise from this permission, can we do something to give execute permission without using ...
1
vote
1answer
28 views

Add one line to all found files

My original working directory hierarchy: $ find . ./usr1 ./usr1/.vimrc ./usr2 ./usr2/.vimrc I want to add one line -- "set number" -- to all .vimrc files. So I ran this command: find -name ...
1
vote
1answer
37 views

use exec -a to name process but run it in the background immune to CTRL-C

I would like to start a background process from bash script, but at the same time give it another name and also make it immune to CTRL-C. I tried the following: exec -a NiceName java -cp ....long ...
10
votes
2answers
710 views

Is there a POSIX way of setting zeroth argument of a target application?

In bash you can use exec -a and in zsh you can alterntavely set ARGV0 to execute a program with a certain zeroth argument but is there also a POSIX way of doing so? As suggested in this one comment ...
1
vote
1answer
28 views

handle large number of same log using cron or logrotate

We have an app deployed in a server, which, under some scenarios, generates some logs in the below format. process_name.hostname.common_text.log.{error/info/warning}.date.time Now, due to this ...
2
votes
1answer
33 views

Using xargs for more commands

Is it possible to use find + xargs in order to invoke more than one command? I am trying to find all files whose size is greater than 100 chars. and less than 1000 chars , change their permissions and ...
4
votes
5answers
217 views

File descriptors across exec

By default file descriptors remain open across the exec functions. The benefit is perhaps understandable for descriptors 0-2. But is there a practical use case for keeping other descriptors open? Are ...
1
vote
1answer
36 views

Create file for every result of find command?

With this line of code I generate an output of every result. exec("find ics/ -mmin +3 -type f -name '*.pdx' -exec basename {} ';' > ./tmp/filename") How can I generate a file with dynamic file ...
1
vote
2answers
42 views

Zeroth argument to an exec function

Here are the standard exec* functions: int execl(const char *path, const char *arg, ...); int execlp(const char *file, const char *arg, ...); int execle(const char *path, const char *arg, ..., char ...
0
votes
1answer
108 views

Cp with full renamed path in execl c program

I need to copy file and rename it in execl function so i did: if ( fileExists(new_dest) ){ /*function in which i rename the file by gtk dialog*/ renameDialog(fileName); ...
0
votes
1answer
57 views

Cron to find exec cp and redirect output with time / date per line?

I try to setup a cron task to run a set of basic shell commands. I need to look to any files created on the last day, then copy to another folder and generate a log stating, line by line, the date ...
1
vote
2answers
38 views

Ignore first x lines when executing a script?

I'm making a script that eventually starts over by executing itself again using exec. The problem is the first few lines are only supposed to be run everytime you launch the script yourself, so I'm ...
3
votes
1answer
60 views

GDB hangs forever on Solaris

GDB seems to hang everytime when I try run command from gdb prompt. When I ran ps, there are two gdb processes that have been spawned and pstack reveals the following - ...
3
votes
2answers
78 views

Using find -exec how to print name of file in front of each line?

Similar to, but beyond: find . -iname "somepatter*txt" -print -exec cat {} \; How might the file name from each file be printed in front of each line with the results from find?
-1
votes
2answers
35 views

how to unzip all files in sub directories

I try to extract all files in all sub directories by this command $ find -name "*.bz2" -print -exec bizp2 -d "*.bz2" {}\; find: missing argument to `-exec' but it doesnot work :( btw I do ...
0
votes
1answer
56 views

fork() and exec() confusion

As when we do fork on current process, our process as parent process generates child process with same characteristics but different process IDs. So after that, when we do exec() in our child process, ...
0
votes
1answer
57 views

How can I display ANSI color in a CLI conky display?

Ideally, I could use something like colortail or multitail and have conky configured to pass the color through, if that is possible. If not, then I need a way to do it some other way. Apologies for ...
3
votes
1answer
61 views

Can I exec an entirely new process without an executable file?

Suppose my non-root 32-bit app runs on a 64-bit system, all filesystems of which are mounted as read-only. The app creates an image of a 64-bit ELF in memory. But due to read-only filesystems it can't ...
6
votes
2answers
64 views

direct execution of python scripts

I have noticed that sometimes python scripts are not being started directly, ie /foo/bar.py, but rather from a shell script, which does nothing else than /usr/bin/python -O /foo/bar.py $@ One such ...
0
votes
1answer
35 views

safe way to redirect some output using exec

I have a script that is rather "noisy". I've been asked to clean up the output so that most of the script's output goes to a log file, and the user just sees the start-up message, and the message when ...
22
votes
3answers
664 views

What does 'exec {fd}</dev/watchdog' do in Bash

That is literal, {fd} isnt a placeholder. I have a script that does this, and does not source in anything, nor does it reference {fd} anywhere else. Is this valid bash? exec {fd}</dev/watchdog
2
votes
1answer
117 views

Cp files into subdirectory with find -exec

Why is this command not copying the 17 .png files into a sub-directory within my current directory? $ find . -maxdepth 1 -mtime -3 | wc -l 17 $ find . -maxdepth 1 -mtime -3 -print0 | grep -z loader ...
0
votes
2answers
77 views

How could I run -exec on find command after | grep

I am on a remote machine attempting to move all loader.gif files into a /Pictures folder find . -iname *.gif | grep loader shows four file I would like to move, naturally I tried: find . -iname *.gif ...
4
votes
2answers
199 views

What does p and e denote in exec family of calls?

l and v in exec calls denote whether the arguments are provided via list or array(vector). I read it somewhere that p denotes the user's path and e denote the environment but did not understand what ...
0
votes
0answers
123 views

Use sudo in apache with SELinux

I am using CentOS 6.5. using Apache, I want to use sudo in exec. It works when SELinux stopped. how to configure SELinux to permit it. The php script <?php exec('sudo -u newuser ls /',$output); ...
1
vote
1answer
102 views

How to convert a generic xml format block to properties format String from an xml file using ksh script [closed]

With the conditions: I cannot use any XML parser tool as I don't have permission , read only My xmllint version does not support xpath, and I cannot update it , read only I dont have xmlstarlet and ...
1
vote
1answer
132 views

How to respond in a prompt using exec channel of JSch

I need to respond to a prompt generated by a command, for example ssh hostname then a password prompt appears and the script must automatically enter the password after the prompt. I tried ...
0
votes
2answers
144 views

Shell Script: Use “find” to execute shell a command that contains “filename”(without extension) returned from “find”

I have several files with extensions "*.f90" in directory-A. I want to apply the following command for each file in shell script. e.g. filename.f90 f2py -h filename.pyf -m filename ...
4
votes
0answers
95 views

Is it possible to make an exec call that “returns”?

Is there a way to make the exec system call work like a function call that returns instead of totally replacing the current process image? My motivation is trying to integrate two shells with ...
5
votes
2answers
264 views

Is it possible to exec some commands in a subshell without immediately exiting afterwards?

I use the fish shell and would like to be able to "source" some shell scripts written with sh-compatible syntax, which fish cannot read. For example lots of software expects you to source some shell ...
0
votes
0answers
107 views

SMB/CIFS mount not working with exec() call

To mount CIFS presently I use system() call in source, this works. If I try to run command manually on shell it works too. $ mount -t cifs //IP/dir /mnt -o user=name,pass=PASS,domain=mydomain,nounix ...
1
vote
1answer
103 views

find with -exec eval of $0 [duplicate]

In the following command I would like to know why $0 was evaluated to the file found by find and not the echo command. $ find . -type f -perm -u=x -exec bash -c ' /bin/echo $0 is the name of the ...
1
vote
1answer
47 views

Reading ELF file after dropping caches

I have an eMMC backed Linux 3.10 development device (Android) and I am trying to better understand when Linux is actually reading from the eMMC as opposed to the page cache. Specifically, I am ...
2
votes
1answer
85 views

How to I prevent exec from keeping the script running?

I'm using exec like this: #!/bin/bash exec > >(tee /tmp/mylog.log) 2>&1 bash -c 'sleep 12312' & I want the output of the commands to be in a log file, and then I want to start a ...
1
vote
3answers
166 views

How do I create a copy of a file in multiple directories?

I have a folder structure conf/ widget1/ env1.cfg env2.cfg widget2/ env1.cfg env2.cfg widget3/ env1.cfg env2.cfg widget4/ ...
3
votes
2answers
313 views

The «sh» being launched with execl() becomes a zombie

I am spent whole half a day, but still couldn't figure, why is the dash being launched with execl call just becomes a zombie. Below is a minimal test case — I'm just fork a child, make a duplicate of ...
0
votes
3answers
195 views

What is meaning of {} + in the exec command?

I want to know the meaning of {} + in the exec command, and what is the difference between {} + and {} \;. To be exact, what is the difference between these two: find . -type f -exec chmod 775 {} + ...
1
vote
1answer
106 views

Find only in directories n levels deep

I use this command to find and run all istances of wp-cron.php I have for each site I have: find /var/www/ -name 'wp-cron.php' -exec php -q "{}" \; Since my websites tree is: ...
0
votes
1answer
565 views

what is the difference between exec and dbus-launch?

If I start a process, particularly at session start, what is the difference between using exec p and dbus-launch p?
2
votes
1answer
71 views

Push onto array with find exec

I want to iterate over all the files found by find and add each one to an array. Here's what I have so far: myarray=() find . -name '*.php' -exec myarray\+=\({}\) \; echo "${myarray[@]}" Instead, ...
3
votes
3answers
716 views

Why do we have to pass the file name twice in exec functions?

I read Advanced Programming in the UNIX Environment by Stevens, 8th chapter. I read and understand all the six of exec functions. One thing I notice is, in all the exec functions: first argument is ...
1
vote
1answer
306 views

Redirect all bash script output (from inside the script) to two files: one append, one rewrite; but discard output to the console

I can easily redirect both standard and error output of a bash script to the file, while discarding an output to console with simple exec statement: exec &>>/var/log/backup.log But how do ...
9
votes
4answers
3k views

How do fork and exec work?

I don't have much experience, just trying to get involved into the processes how do they interpret to hardware from user level. So when a command is fired from a shell, fork() inherits a child ...
2
votes
4answers
3k views

Bash rename 360 000 files using find -exec

I've got around 360 000 files like: ./001/1/1.jpg ./001/1/2.jpg ./001/2/1.jpg ./002/1/1.jpg ./003/1/1.jpg ... pattern: [60 dirs]/[1000 subdirs]/[4-10 files].jpg I want to rename files using rename ...
-1
votes
3answers
671 views

How to print the base file name using find in Unix?

I have been trying to print out the base file names using find in Unix. To simply print out the file names the command I have been using is this find . -type f -name \*.out -print It prints out ...
2
votes
1answer
1k views

GDB cannot exec my test program

My computer run with Ubuntu 14.04. GDB seems to be abnormal in different account. For example I make a very simple test. I write a file under ~/test/test.c like this: #include <stdio.h> ...
4
votes
2answers
1k views

How does exec bash builtin work internally?

From this link I get the following about exec bash builtin command: If command is supplied, it replaces the shell without creating a new process. How does it exactly replace the shell (i.e. ...
1
vote
1answer
132 views

exec -t is invalid

I made an rpm that installs a .run file and whenever I run the rpm and the rpm tries to execute the .run file I keep getting the error that exec -t is an invalid option at the following lines of code ...
1
vote
2answers
117 views

If I use one of the exec family functions to open a child process, will pipes to parent be applied to the child?

Say I open a parent process with a master process that assigns the stdout to a file for logging. Then say I use the parent process to open a child with execvp (or any other of the exec family of ...