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

Execute two commands with docker exec

I'm trying to do two commands in docker exec. Concretely, I have to run a command inside a specific directory. I tried this, butit didn't work: docker exec [id] -c 'cd /var/www/project && composer install' Parameter -c is not detected. I also tried…
BraveAdmin
  • 685
  • 1
  • 6
  • 15
24
votes
3 answers

php exec() background process issues

I'm trying to process a file in the background with the following command, but it does nothing. exec("php csv.php $file $user > /dev/null &", $output); If I remove > /dev/null & then the file processes, but not in the background. exec("php csv.php…
kylex
  • 14,178
  • 33
  • 114
  • 175
24
votes
3 answers

In C how do you redirect stdin/stdout/stderr to files when making an execvp() or similar call?

I have the following code: pid_t pid = fork(); if (pid == -1) { // ... } else if (pid == 0) { stdin = someopenfile; stdout = someotherfile; stderr = somethirdopenfile; execvp(args[0], args); // handle error ... } else { …
Matt
  • 21,026
  • 18
  • 63
  • 115
23
votes
5 answers

calling exec on a php file and passing parameters?

I am wanting to call a php file using exec. When I call it I want to be able to pass a variable through (an id). I can call echo exec("php /var/www/unity/src/emailer.php"); fine, but the moment I add anything like echo exec("php…
Hailwood
  • 89,623
  • 107
  • 270
  • 423
23
votes
3 answers

Passing value from PHP script to Python script

I looked at the other questions similar to this one, but can't figure this out still. I have a basic php file that does this: ?php $item='example'; $tmp = exec("python testscriptphp.py .$item"); echo $tmp; ? While succesfully calls python that I…
stackVidec
  • 291
  • 1
  • 5
  • 8
23
votes
4 answers

Redirect Runtime.getRuntime().exec() output with System.setOut();

I have a program Test.java: import java.io.*; public class Test { public static void main(String[] args) throws Exception { System.setOut(new PrintStream(new FileOutputStream("test.txt"))); System.out.println("HelloWorld1"); …
Leo Izen
  • 4,165
  • 7
  • 37
  • 56
23
votes
6 answers

PHP exec() performance

The following PHP code does return me a runtime of about 3.5 seconds (measured multiple times and averaged): $starttime = microtime(true); exec('/usr/local/bin/convert 1.pdf -density 200 -quality 85% 1.jpg'); $endtime = microtime(true); $time_taken…
Philipp
  • 535
  • 1
  • 6
  • 16
22
votes
4 answers

What is the difference between spawn and exec?

I'm learning to write a TCL (expect) scripts and I notice that some examples show to use spawn, while others show the command exec. I tried googling, but can't find what is the difference? Suppose I call 'exec' in a middle of a long expect script,…
Milan Babuškov
  • 59,775
  • 49
  • 126
  • 179
22
votes
3 answers

Running python script in Laravel

So, I am trying to run a python script in my Laravel 5.3. This function is inside my Controller. This simply passes data to my python script public function imageSearch(Request $request) { $queryImage =…
Carriane Lastimoso
  • 233
  • 1
  • 2
  • 7
22
votes
2 answers

How do I fork a go process?

I want to fork a go process and get back the id of the new process(es), but all I can see in the exec or os libraries is to start a new process.
Shashwat
  • 2,538
  • 7
  • 37
  • 56
22
votes
4 answers

Nodejs child_process.exec : Disable printing of stdout on console

I am performing an image magick identify command via nodejs child_process.exec. and using the string returned from stdout in my script. Everything works fine but the call prints the stdout msg on console, if the server is not restarted and the…
hussainb
  • 1,218
  • 2
  • 15
  • 33
21
votes
2 answers

Write to child process' stdin in Rust?

Rust's std::process::Command allows configuring the process' stdin via the stdin method, but it appears that that method only accepts existing files or pipes. Given a slice of bytes, how would you go about writing it to the stdin of a Command?
joshlf
  • 21,822
  • 11
  • 69
  • 96
21
votes
1 answer

Kubectl exec command to write contents to a file in the pod

I am trying below command kubectl exec -it sss-pod-four echo "hi" >> /mnt/sss/testnew.txt But it throws error -bash: /mnt/sss/testnew.txt: No such file or directory What is the best way to achieve this
ambikanair
  • 4,004
  • 11
  • 43
  • 83
21
votes
5 answers

Check if "exec" is disabled

Is there any function in PHP that I can use to detect whether or not the exec function is available?
esqew
  • 42,425
  • 27
  • 92
  • 132
21
votes
3 answers

Maven Exec Plugin : How configure the working directory

I'm using the Exec Maven plugin with the following command : mvn exec:java and I didn't manage to set the working directory with this execution mode. I want to use a mainClass (in a specific package) and I want the root folder of my execution in…
user1842947
  • 1,047
  • 1
  • 11
  • 16