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
19
votes
5 answers

How to get java getRuntime().exec() to run a command-line program with arguments?

I've been trying to write a java program that uses the Runtime.getRuntime().exec() method to use the command-line to run an instance of the program "tesseract". Some background, Tesseract is a free open source program that is used to perform OCR…
Samuel
  • 574
  • 3
  • 7
  • 22
19
votes
3 answers

Wildcards in child_process spawn()?

I want to execute a command like "doSomething ./myfiles/*.csv" with spawn in node.js. I want to use spawn instead of exec, because it is some kind of watch process and I need the stdout output. I tried this var spawn =…
Torben
  • 1,290
  • 5
  • 22
  • 41
18
votes
4 answers

Runtime.exec() bug: hangs without providing a Process object

Whether I use this: process = Runtime.getRuntime().exec("logcat -d time"); or that: process = new ProcessBuilder() .command("logcat", "-d", "time") .redirectErrorStream(true) .start(); I get the same…
3c71
  • 4,313
  • 31
  • 43
18
votes
3 answers

Is the unix fork exec sequence really as expensive as it sounds?

I'm reading about fork and exec for an exam, and my book says that whenever it is needed to run a new (different) process in unix systems, you would fork the current process followed by an execve. However, it also says that whenever fork is called,…
bobbaluba
  • 3,584
  • 2
  • 31
  • 45
18
votes
3 answers

understanding requirements for execve and setting environment vars

We are having a lot of trouble interpreting our teacher. We asked for clarification and got the following back from him For execve, send it a environment you setup with your exported variables and create a builtin command to spawn a subshell of…
james
  • 712
  • 4
  • 11
  • 29
18
votes
4 answers

Using xcopy to copy files from several directories to one directory

Is it possible to use xcopy to copy files from several directories into one directory using only one xcopy command? Assuming that I have the directory tree root\Source\Sub1\Sub2 I want to copy all .xml files from the directory root\Source including…
Oddleif
  • 751
  • 3
  • 9
  • 35
18
votes
3 answers

using exec to execute a system command in a new process

I am trying to spawn a process that executes a system command, while my own program still proceeds and two processes will run in parallel. I am working on linux. I looked up online and sounds like I should use exec() family. But it doesn't work…
CuriousMind
  • 15,168
  • 20
  • 82
  • 120
18
votes
1 answer

Capturing exit status code of child process

I have a function that forks a process, duplicates file descriptors for input and output buffers, and then runs execl on a command passed in via a string called cmd: static pid_t c2b_popen4(const char* cmd, int pin[2], int pout[2], int perr[2], int…
Alex Reynolds
  • 95,983
  • 54
  • 240
  • 345
18
votes
3 answers

Gradle: task's standardOutput to file and terminal simultaneously

I want to change standardOutput of one build task to file, because it will be parsed later by another task. But also, I would like to have simultaneously output in the terminal to see what's going on in the build. This is how I changed output of the…
Artem Zinnatullin
  • 4,305
  • 1
  • 29
  • 43
18
votes
3 answers

Execute external command

I do not know whether it is a Scala or Play! question. I want to execute some external command from my Play application, get the output from the command and show a report to user based on the command output. Can anyone help? For example, when I…
Khalid Saifullah
  • 747
  • 2
  • 8
  • 21
18
votes
2 answers

php background process using exec function

I have searched a lot to find the exact answer but didn't find any. many people mentioned that we should & at end of command to don't wait for response. for example to run bg.php in background , this was recommended: exec("/usr/bin/php bg.php…
Aliweb
  • 1,891
  • 3
  • 21
  • 44
18
votes
1 answer

How to get the results (standard output) of a TCL exec command?

Say I have a TCL script like this: exec ls -l Now this will print out the content of current directory. I need to take that output as a string and parse it. How I can do this?
Narek
  • 38,779
  • 79
  • 233
  • 389
17
votes
1 answer

Best way to sanitize exec command with user inserted variables

I'm coding a web interface to a horrible piece of propitiatory software our company uses. The software has no real UI and requires us giving putty access to our system for our clients to even pull data. My web interface has to run an exec();…
The Digital Ninja
  • 1,090
  • 6
  • 22
  • 36
17
votes
1 answer

Running Shell commands though java code on Android?

I've got an app that's supposed to use some shell commands to copy a file from the sdcard to /system/media/. It will require root, and I am testing on a rooted device. I'm using runtimes to execute the shell commands, but it's not working. Here's…
Ben
  • 758
  • 1
  • 8
  • 19
17
votes
4 answers

Java Runtime exec() fails to escape characters properly

This might already been answered before but that was regarding unicode and I don't think this is unicode (it's in ASCII so...). When I execute this in my terminal there is no problem what so ever vboxmanage setextradata "Test Machine"…
Tim Strijdhorst
  • 1,539
  • 3
  • 14
  • 29