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
17
votes
8 answers

how to use a bash function defined in your .bashrc with find -exec

my .bashrc has the following function function myfile { file $1 } export -f myfile it works fine when i call it directly rajesh@rajesh-desktop:~$ myfile out.ogv out.ogv: Ogg data, Skeleton v3.0 it does not work when i try to invoke it through…
sharrajesh
  • 401
  • 1
  • 5
  • 12
17
votes
3 answers

system() vs execve()

Both system() and execve() can be used to execute another command inside a program. Why in set-UID programs, system() is dangerous, while execve() is safe ?
Jake
  • 16,329
  • 50
  • 126
  • 202
17
votes
3 answers

Running at from PHP gives no output

I've been wrestling with exec(), trying to capture the output from it when I add a task using the at Unix system command. My problem is that it is giving no output when run from my script, however running it from the terminal and PHP in interactive…
Bojangles
  • 99,427
  • 50
  • 170
  • 208
16
votes
2 answers

Node.js spawn with colors?

I'm using Mocha for testing my apps. Currently, I'm using Makefiles, but I want to switch to Cakefiles. When I run my test through Cake, the colors from Mocha are not displayed on console. Here's an example: task 'test', 'test project', (options)…
JP Richardson
  • 38,609
  • 36
  • 119
  • 151
16
votes
6 answers

Can't execute PHP script using PHP exec

I am trying to invoke a script which takes several seconds (web services with 3rd party) using the PHP exec call. After much struggling, I reduced this to the classic hello world example. The calling script looks like: exec('/usr/bin/php…
Steve
16
votes
7 answers

PHP exec() and spaces in paths

I'm executing the following in a PHP application: $source = '/home/user/file.ext'; $output_dir = $this->setOutputString(); chdir('/home/ben/xc/phplib/bgwatcher-2011a/a01/'); exec('php bin/createjob.php $source $output_dir', $output); …
b. e. hollenbeck
  • 6,493
  • 7
  • 32
  • 47
16
votes
3 answers

set @var = exec stored_procedure

Is it possible to assign at variable a value returned from exec stored procedure? Something like DECLARE @count int SET @count = Execute dbo.usp_GetCount @Id=123
BumbleBee
  • 10,429
  • 20
  • 78
  • 123
16
votes
4 answers

Switch user without creating an intermediate process

I'm able to use sudo or su to execute a command as another user. By combining with exec, I'm able to replace the current process with sudo or su, and a child process running the command. But I want to replace the current process with the command…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
16
votes
2 answers

Difference between exec and execute in php

I'm learning php but in the tutorial I use, I can see something like these lines : $DatabaseAdd->exec('INSERT INTO db_name...... and this one : $request->execute(array(..... Is there any difference between exec and execute? Can we use one to…
freij
  • 163
  • 1
  • 1
  • 7
16
votes
2 answers

What does this command do? "exec bash -l"

What does this command do? exec bash -l I found this command as part of a reminder text file were I wrote some instructions regarding how to create a ssh key and clone a git repo, but I wrote it a long time ago and I can't remember what it does.
matiascelasco
  • 1,145
  • 2
  • 13
  • 18
16
votes
5 answers

Why won't Go kill a child process correctly?

The following works just fine when cmd finishes in the allotted time. However, the timeout is not working. While it does print "It's dead Jim", not only does it fail to print "Done waiting", but the process is not actually killed. It continues to…
Floegipoky
  • 3,087
  • 1
  • 31
  • 47
16
votes
3 answers

Mvn compile before exec

I am trying to set up my POM such that when I do mvn exec:exec or mvn exec:java it will first compile the source and iff successful, execute it. I have the following and have tried moving the part about but can't get it to work:
Lerp
  • 2,957
  • 3
  • 24
  • 43
16
votes
6 answers

How to handle execvp(...) errors after fork()?

I do the regular thing: fork() execvp(cmd, ) in child If execvp fails because no cmd is found, how can I notice this error in parent process?
Łukasz Lew
  • 48,526
  • 41
  • 139
  • 208
15
votes
1 answer

What is the difference between execl and execv?

I use execv instead of execl. To use execv, I create an array and put arguments that I use with execl in there. Then I put this array into execv I know I have to use an array of arguments for execv but why? What is the difference between execl and…
Ahmet Tanakol
  • 241
  • 1
  • 7
  • 13
15
votes
2 answers

Save result of stored procedure in a Table variable

Possible Duplicate: How to SELECT * INTO [temp table] FROM [stored procedure] I have a nested stored procedure call In one of the stored procedures I want to save the result into a table variable likt this : INSERT INTO @myTable EXEC…
Jan
  • 9,858
  • 7
  • 26
  • 33