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
565
votes
3 answers

What's the difference between eval, exec, and compile?

I've been looking at dynamic evaluation of Python code, and come across the eval() and compile() functions, and the exec statement. Can someone please explain the difference between eval and exec, and how the different modes of compile() fit in?
andrewdotnich
  • 16,195
  • 7
  • 38
  • 57
486
votes
14 answers

How do I execute a string containing Python code in Python?

How do I execute a string containing Python code in Python? Do not ever use eval (or exec) on data that could possibly come from outside the program in any form. It is a critical security risk. You allow the author of the data to run arbitrary code…
hekevintran
  • 22,822
  • 32
  • 111
  • 180
422
votes
4 answers

Ruby, Difference between exec, system and %x() or Backticks

What is the difference between the following Ruby methods? exec, system and %x() or Backticks I know they are used to execute terminal commands programmatically via Ruby, but I'd like to know why there are three different ways to do this.
Mr. Black
  • 11,692
  • 13
  • 60
  • 85
393
votes
4 answers

PHP shell_exec() vs exec()

I'm struggling to understand the difference between shell_exec() and exec()... I've always used exec() to execute server side commands, when would I use shell_exec()? Is shell_exec() just a shorthand for exec()? It seems to be the same thing with…
Ben
  • 60,438
  • 111
  • 314
  • 488
342
votes
5 answers

PHP exec() vs system() vs passthru()

What are the differences? Is there a specific situation or reason for each function? If yes, can you give some examples of those situations? PHP.net says that they are used to execute external programs. see reference From the examples I see, I don't…
codingbear
  • 14,773
  • 20
  • 48
  • 64
298
votes
2 answers

What are the uses of the exec command in shell scripts?

Can anyone explain what are the uses of the exec command in shell scripting with simple examples?
user2400564
  • 4,619
  • 7
  • 24
  • 27
294
votes
13 answers

find: missing argument to -exec

I was helped out today with a command, but it doesn't seem to be working. This is the command: find /home/me/download/ -type f -name "*.rm" -exec ffmpeg -i {} -sameq {}.mp3 && rm {}\; The shell returns find: missing argument to `-exec' What I am…
Abs
  • 56,052
  • 101
  • 275
  • 409
251
votes
5 answers

The difference between fork(), vfork(), exec() and clone()

I was looking to find the difference between these four on Google and I expected there to be a huge amount of information on this, but there really wasn't any solid comparison between the four calls. I set about trying to compile a kind of basic…
user476033
  • 4,607
  • 8
  • 32
  • 35
238
votes
9 answers

Differences between fork and exec

What are the differences between fork and exec?
Sashi
  • 3,069
  • 6
  • 20
  • 18
217
votes
14 answers

node.js execute system command synchronously

I need in node.js function result = execSync('node -v'); that will synchronously execute the given command line and return all stdout'ed by that command text. ps. Sync is wrong. I know. Just for personal use. UPDATE Now we have mgutz's solution…
disfated
  • 10,633
  • 12
  • 39
  • 50
156
votes
5 answers

How to execute an external program from within Node.js?

Is it possible to execute an external program from within node.js? Is there an equivalent to Python's os.system() or any library that adds this functionality?
Michael Bylstra
  • 5,042
  • 4
  • 28
  • 24
149
votes
11 answers

Running a Python script from PHP

I'm trying to run a Python script from PHP using the following command: exec('/usr/bin/python2.7 /srv/http/assets/py/switch.py arg1 arg2'); However, PHP simply doesn't produce any output. Error reporting is set to E_ALL and display_errors is…
Abandoned account
  • 1,855
  • 2
  • 16
  • 22
121
votes
4 answers

How to make pipes work with Runtime.exec()?

Consider the following code: String commandf = "ls /etc | grep release"; try { // Execute the command and wait for it to complete Process child = Runtime.getRuntime().exec(commandf); child.waitFor(); // Print the first 16 bytes of…
poundifdef
  • 18,726
  • 23
  • 95
  • 134
113
votes
13 answers

How to execute file I'm editing in Vi(m)

How to execute file that I'm editing in Vi(m) and get output in split window (like in SciTE)? Of course I could execute it like that: :!scriptname But is it posible to avoid writing script name and how to get output in split window instead just…
Alex Bolotov
  • 8,781
  • 9
  • 53
  • 57
110
votes
10 answers

How to invoke external command from within Kotlin code?

I want to invoke an external command from Kotlin code. In C/Perl, I would use the system() function. In Python, I would use the subprocess module. In Go, I would use os/exec, and etc. But how do I do this in Kotlin?
Big Tummy
  • 1,141
  • 2
  • 8
  • 3
1
2 3
99 100