Questions tagged [exec]

This tag refers to the starting of another, subsidiary program. It is named after the family of POSIX system calls whose name starts with “exec” (notably “execve”) though similar concepts exist on other platforms as well, especially when combined with the starting up of another process.

From The Open Group Base Specifications Issue 7

The exec family of functions shall replace the current process image with a new process image. The new image shall be constructed from a regular, executable file called the new process image file. There shall be no return from a successful exec, because the calling process image is overlaid by the new process image.

This tag is commonly used with when it refers to execute an external program within a php code.

Examples

echo exec('whoami');

References

5914 questions
108
votes
4 answers

difference between docker attach and docker exec

Both will be able to execute commands in container. Both could detach the container. So what is the real difference between docker exec and docker attach?
MJL
  • 1,235
  • 2
  • 10
  • 6
107
votes
3 answers

What are the different versions of exec used for in C and C++?

These are all the versions of exec that can be used in C (and C++) execl execle execlp execv execve execvp What's the difference between them? How do you know which one to use?
node ninja
  • 31,796
  • 59
  • 166
  • 254
104
votes
5 answers

Why does find -exec mv {} ./target/ + not work?

I want to know exactly what {} \; and {} \+ and | xargs ... do. Please clarify these with explanations. Below 3 commands run and output same result but the first command takes a little time and the format is also little different. find . -type f…
Shahadat Hossain
  • 2,542
  • 3
  • 17
  • 13
91
votes
7 answers

php exec command (or similar) to not wait for result

I have a command I want to run, but I do not want PHP to sit and wait for the result. Is it possible to have PHP not wait for the result.. i.e.…
greg
  • 911
  • 1
  • 7
  • 6
90
votes
4 answers

How get exec task output with msbuild

I'm trying to get simple output by exec task with msbuild:
tbicr
  • 24,790
  • 12
  • 81
  • 106
90
votes
5 answers

docker-exec failed: "cd": executable file not found in $PATH

I used this command: docker exec compassionate_mclean cd /root/python The error returned is docker-exec: failed to exec: exec: "cd": executable file not found in $PATH Kindly help me out
sabarish
  • 1,059
  • 1
  • 11
  • 14
80
votes
5 answers

Bash scripts with tmux to launch a 4-paned window

Can anyone help explain what's going on with tmux, bash, and exec? I'm trying to set up a tmux session with a 4-pane window. Ideally, I want to run a command in 3 of the panes: e.g. a Ruby Thin server and a couple of Ruby daemons. This is what I…
Aaron Gibralter
  • 4,773
  • 3
  • 35
  • 50
80
votes
2 answers

How to debug "exit status 1" error when running exec.Command in Golang

When I run the code below: cmd := exec.Command("find", "/", "-maxdepth", "1", "-exec", "wc", "-c", "{}", "\\") var out bytes.Buffer cmd.Stdout = &out err := cmd.Run() if err != nil { fmt.Println(err) return } fmt.Println("Result: " +…
laurent
  • 88,262
  • 77
  • 290
  • 428
79
votes
17 answers

How to add a timeout value when using Java's Runtime.exec()?

I have a method I am using to execute a command on the local host. I'd like to add a timeout parameter to the method so that if the command being called doesn't finish in a reasonable amount of time the method will return with an error code. …
James Adams
  • 8,448
  • 21
  • 89
  • 148
79
votes
12 answers

Difference between "system" and "exec" in Linux?

What is the difference between system and exec family commands? Especially I want to know which one of them creates child process to work?
Kamil
  • 799
  • 1
  • 5
  • 3
77
votes
2 answers

PHP: Why isn't exec() returning output?

I'm writing a PHP script to be used to check for network connections with Linux shell command ping calling it with PHP's exec():
Edward
  • 9,430
  • 19
  • 48
  • 71
73
votes
6 answers

PHP StdErr after Exec()

In PHP I am executing a command with exec(), and it returns if successful an URL; $url = exec('report'); However, I want to check stderr, if something went wrong. How would I read the stream? I want to use php://stderr, but I am not sure how to use…
martin
  • 949
  • 3
  • 11
  • 18
69
votes
3 answers

Run Bash Command from PHP

I have a bash script, that I run like this via the command line: ./script.sh var1 var2 I am trying to execute the above command, after I call a certain php file. What I have right now is: $output = shell_exec("./script.sh var1 var2"); echo…
r0skar
  • 8,338
  • 14
  • 50
  • 69
68
votes
1 answer

What are the differences of system(), exec() and shell_exec() in PHP?

It is possible to run an external command by three PHP functions of system(); exec(); shell_exec(); but what are their differences? In spite of their specific applications, in most cases, the can be equally used. I am curious to know which is…
Googlebot
  • 15,159
  • 44
  • 133
  • 229
61
votes
7 answers

How do I launch a completely independent process from a Java program?

I am working on a program written in Java which, for some actions, launches external programs using user-configured command lines. Currently it uses Runtime.exec() and does not retain the Process reference (the launched programs are either a text…
Lawrence Dol
  • 63,018
  • 25
  • 139
  • 189