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

How to pass arguments in php exec()?

I am trying to run a .exe application with input file and argument. With cmd I can successfully start the executable like this... C:\Program Files\MyApp.exe "path\to\input file" argument However, nothing happens when I simply copy paste the string…
Skogen
  • 721
  • 1
  • 11
  • 30
2
votes
3 answers

Easiest way to execute linux program and communicate with it via stdin/stdout in C/C++

I have program I cant modify, as is, and I need to execute it, write some data to its stdin and get the answer from its stdout in programmatic manner, automated. What is the simpliest way to do this? I suppose something like this pseudo-C-code char…
kernelbug
  • 151
  • 1
  • 2
  • 13
2
votes
1 answer

Run multiple ssh commands using execl

I want to execute the following command from my C program: ssh -t -t root@192.168.3.21 "export LINES=40;export COLUMNS=124;export TERM=xterm;$SHELL -i" 0 < t_in 1 > t_out If I am using system call as in: system("ssh -t -t root@192.168.3.21 \"export…
2
votes
1 answer

Error "Declare Scalar" when Dynamic Exec Update inside two Cursor loops

Basically I'm looking to loop through a temp table which lists certain table names which need updated, I take each table name use it to populate another temporary table of all the ID's which are to be updated.. I can select the data in each table…
2
votes
1 answer

execl won't, well, execute

Working on a project and when I call execl() it is not working. It is called after a fork and is supposed to reexecute the current file. (argument is declared earlier in the file): argument = argv[0]; int err =execl(argument, argument, left, "1",…
ReezaCoriza
  • 133
  • 4
  • 16
2
votes
2 answers

exec to add a function into a class

So I've looked at similar questions, and I've found some solutions to this, but I can't quite figure out how to do this. What I'm trying to do is add a method to a class from a string. I can do this with the setattr() method, but that won't let me…
Hovestar
  • 1,544
  • 4
  • 18
  • 26
2
votes
1 answer

Python using exec with custom globals

I would like to create a simple python shell. So right now I am stuck on executing the code. The question is, is there a way to run exec with custom globals? Thanks
JadedTuna
  • 1,783
  • 2
  • 18
  • 32
2
votes
2 answers

Adding tasks to Windows scheduler with PHP

I'm unable to find any information on adding tasks to Windows Task Scheduler with PHP. I can use exec(). This has to work on IIS.
Tower
  • 98,741
  • 129
  • 357
  • 507
2
votes
1 answer

How to use php exec() to execute a command in Linux and bind the output to an array?

I'm performing an egrep in Linux using PHPs exec(). The output is a list of files when actually executing this statement from the command line in Linux. When I echo the result in PHP it only displays the last line of the output. I want to bind this…
blarg
  • 3,773
  • 11
  • 42
  • 71
2
votes
1 answer

python exec, add staticmethod to class

In python I can do: exec(code_string, globals(), some_object.__dict__) to add a method to an object. Is it possible to add a static method to a class in some sort of similar fashion? Like: exec(code_string, globals(), ClassName.__dict__) So that I…
lanthica
  • 250
  • 1
  • 9
2
votes
1 answer

How to correctly receive data from pipes?

So I wrote a program using pipes and execl to do some arithmetic. I'm not sure how to debug pipes and different processes, but from what I can see it has to have something to do with my pipes reading the numbers. So my setup so far is the children…
Janae
  • 65
  • 2
  • 5
2
votes
2 answers

mkdir fails in the /tmp directory

I'm trying to create a folder in php and the code kind of fails each it is used with /tmp/... as path: exec("mkdir -p /tmp/test/ 2>&1", $output, $return_code); // $output is empty, $return_code is 0 //mkdir("/tmp/test/"); // Alternative to…
Daishy
  • 238
  • 2
  • 11
2
votes
3 answers

PHP: Using SVN subcommands and options in exec() causes "segmentation fault"?

There is something that drives me nuts these days since I cannot continue my work on a project. I've switched to another computer and can't get PHP and svn executable to work together nicely :) $output = ""; $value = ""; …
Oliver Maksimovic
  • 3,204
  • 3
  • 28
  • 44
2
votes
1 answer

telnet connection inputstream blocking why?

package burak; import java.io.*; public class telcon { public static void main(String[] args) { try { String[] command=new String[2]; command[0]="cmd /c start cmd.exe /k \"telnet\""; …
2
votes
1 answer

Running a python script from php with system( ) or even passthru( ) produces no output. Why?

I need to run a python script (a log parser) on hundreds of log files, but I'm a PHP guy so I figured I'd write a little PHP script to grab the list of files from a directory and call the python script dynamically in a foreach loop. I've set…
phpguru
  • 2,351
  • 2
  • 23
  • 33