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
21
votes
2 answers

Running external commands through os/exec under another user

Using the os/exec package, I want to run an external command on a *nix OS, on behalf of another user (of course go process run under root user of another user with su privileges) I want avoid "su" or "bash" commands and make it purely with go. I…
mcuadros
  • 4,098
  • 3
  • 37
  • 44
21
votes
4 answers

Windows CMD.exe "The system cannot find the path specified."

Solved by restoring Windows to previous state The message (The system cannot find the path specified.) shows... 1) When i open new CMD (Win+R => cmd). It starts with introduction. (on line 3) Microsoft Windows [Version 6.1.7601] Copyright (c) 2009…
ViliamKopecky
  • 313
  • 1
  • 2
  • 7
21
votes
3 answers

execute file from defined directory with Runtime.getRuntime().exec

I just want to execute my file from a specific folder. in my case /data/data/my-package/files/. So i tried : Process process2=Runtime.getRuntime().exec("cd /data/data/my-package/files/"); process2.waitFor(); …
113408
  • 3,364
  • 6
  • 27
  • 54
20
votes
4 answers

Executing git commands via PHP

How can git commands like git add . and git commit -m be executed using php? It is for a project that creates a centralized repository facility for maintaining academic projects. exec() didn't seem to work.
rjv
  • 6,058
  • 5
  • 27
  • 49
20
votes
3 answers

Running command-line application from PHP as specific user

I am running Apache on my localhost. From a PHP script run as www-user I would like to control Rhythmbox playback on my machine. So far I have a simple command in my PHP script: exec('rhythmbox-client --pause'); This works great when I run it from…
Tak
  • 11,428
  • 5
  • 29
  • 48
20
votes
7 answers

How can I ensure all output from Ant's exec task goes to stdout?

The Ant exec task has an output property which can be used to tell Ant where the output goes. I've used it to redirect the output to a file. The thing is, if I don't do something with the output, the stuff that Ant prints isn't that much of a help -…
Geo
  • 93,257
  • 117
  • 344
  • 520
20
votes
3 answers

Display running child process' output in nodejs (windows)

For example sake, I'm running the most basic webServer in node (I'm using windows) with the following code (named server.js): var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type':…
mayorbyrne
  • 495
  • 1
  • 5
  • 16
20
votes
3 answers

PHP exec change encoding

I need to address UTF-8 filenames with the php exec command. The problem is that the php exec command does not seem to understand utf-8. I use something like this: echo exec('locale charmap'); returns ANSI_X3.4-1968 looking at this SO question, the…
The Bndr
  • 13,204
  • 16
  • 68
  • 107
19
votes
3 answers

How to exit a child process and return its status from execvp()?

In my simple custom shell I'm reading commands from the standard input and execute them with execvp(). Before this, I create a fork of the current process and I call the execvp() in that child process, right after that, I call exit(0). Something…
rfgamaral
  • 16,546
  • 57
  • 163
  • 275
19
votes
3 answers

Executing a Command from Java and Waiting for the Command to Finish

In my Java program, I create a process that executes a command to run a batch file like this: try { File tempFile = new File("C:/Users/Public/temp.cmd"); tempFile.createNewFile(); tempFile.deleteOnExit(); …
Matt R. Johnson
  • 783
  • 1
  • 7
  • 14
19
votes
3 answers

How to find -exec cd in linux / unix

I'm searching for a config folder, and trying to change to that directory: find . -name "config" -exec cd {} \; There is one match, ./my-applications/config, but after I try this it says: find: `cd': No such file or directory What am I doing…
cwd
  • 53,018
  • 53
  • 161
  • 198
19
votes
1 answer

exec: executable file not found in $PATH

I am trying to send the HUP signal to tor in Go. command := exec.Command("pidof tor | xargs kill -HUP") command.Dir = "/bin" if cmdOut, err := command.CombinedOutput(); err != nil { log.Panic("There was an error running HUP ",…
Mathieu Nls
  • 2,285
  • 2
  • 17
  • 32
19
votes
4 answers

Golang exec process and to disown it

I am trying to fork processes with my daemon, and trying to disown them in case of my daemon crashes. Regular os/exec is high-level, therefore I went for syscall.ForkExec and produced the following code: package main import ( "fmt" "os" …
Mustafa
  • 10,013
  • 10
  • 70
  • 116
19
votes
1 answer

Why are closures broken within exec?

In Python 2.6, >>> exec "print (lambda: a)()" in dict(a=2), {} 2 >>> exec "print (lambda: a)()" in globals(), {'a': 2} Traceback (most recent call last): File "", line 1, in File "", line 1, in File "",…
Devin Jeanpierre
  • 92,913
  • 4
  • 55
  • 79
19
votes
2 answers

how to set close-on-exec by default

I'm implementing a library to run commands. The library is C, on Linux. It currently does a popen() call to run a command and get output. The problem is that the command inherits all currently open file handlers. If I did a fork/exec I could close…
n-alexander
  • 14,663
  • 12
  • 42
  • 43