exec

Redirect cmd output to string in c++ or in memobox?

I have two objects in my form application. First is a listbox where i want to hold the cmd output, and the second is button who have command like, WinExec("cmd /c ipconfig -all", 0);, so question is how to redirect cmd output to the list box. For example, I'd prefer not to save output of ipconfig in file & load from file text to list box...

Behavior of Python exec() differs depending on the where it is called from

I have a Python script 'runme.py' that I am trying to execute from 'callerX.py' below. I am using exec(open(filename).read()) to accomplish this task. The script being executed contains a simple class that attempts to call the 'time()' function both from the global namespace & inside a function. In all of the examples below, we are exec...

exec() (or like functions) pass back error output

I can pass back output of the executed script, but I get no error output if the script errors out. // This is a file that doesn't exists, for testing $command = './path/to/non/existing/script.sh'; $commandOutput = exec($command, $commandOutput); // works but no error output //passthru($command, $commandOutput); // works but error outpu...

Catch background process error in PHP?

How can I catch a background process error in PHP? I am running some commands to convert a PDF but sometimes the process gets killed. Is there anyway to monitor if the process has been completed successful ? ...

imagick binary to count number of pages in a pdf file

Hi Could someone suggest the php code using exec() function to execute a binary of imagick to count the pages in a pdf file. Any suggestions would be great. Thanks! Regards Rahul ...

right path of image being referred to in exec() in php

Hi I am trying to use the following script to count the number of pdf pages in a pdf file. $filename = $_ENV{'HOMEDIR'}."/www/path/to/pdf/file"; $cmd = "/usr/local/nf/bin/identify -density 12 -format '%p' '$filename' "; $out = array(); exec($cmd,$out,$error); foreach($out as $f=>$v) { echo "$f = $v "; } However I get no outp...

How to find PID of an dash-exec command

NOTE: I thought I was using bash, but /bin/sh is linked to /bin/dash, which has this weird exec problem. I have a simple bash shell script on Linux which is used to launch a server process (which I did not write or control) and would like to have the bash shell script output the launched process's PID to a pidfile. The problem is that ...

Passing a filename via a variable to tar from within PHP?

I am trying to ultimately extract some files from a tar archive within PHP, however my simple test script is failing at the first part, which was to simply list the files in the archive. Is there any reason why this test script fails? What I see output is: > -sh-3.2$ php showfile.php /var/www/vhosts/smartphonesoft.com/httpdocs/fred/ep...

How to disable PHP's exec function for printing to the shell?

I have the following php code: exec('curl -X POST http://mysite.com', $output =array()); The return string my http://mysite.com is not displayed on the shell, but the following string is displayed: % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total ...

How to disable windows application crash reporting?

I am trying to invoke external program (in my case IECapt.exe) in php function exec() on windows. It works well most of the time, but when IECapt.exe crash, windows pop-up a crash prompt window, and php script hangs there wait this prompt window closed, so how to disable such pop-up crash window? because my php script need run as a da...

PHP system() args

I have the following code that executes a C++ program and outputs it: <html> <head> <title>C++</title> </head> <body> <div><?php system("app.exe", $out); echo rtrim($out, "0"); ?></div> </body> </html> How can I make it so that you can pass arguments to the c++ program, say like this... If this was the c...

Unused Return Status Codes in C

I want to return a unique status code to a waiting parent process from a child process through exit(), based on the execution of child's code. If execvp fails, then the exit() is used. I assume that if execvp is successful, the command executed will send its status code. pid=fork(); if(pid==0) { if(execvp(cmdName,cmdArgs)==-1) {...

php exec tar call fails when run via cron, works via shell

Can anyone explain why this line works when called from shell, but fails when called via crontab? passthru("tar xvf $file $tarfile/application $tarfile/application_detail $tarfile/application_device_type $tarfile/genre_application"); } The error I got emailed after cron was tar: itunes20100907/application: Cannot open: No such f...

-C option is ignored when calling tar via PHP

If I run my PHP file from the shell, then the tar command extracts to the directory I am in, rather than the one I specified using -C My command is passthru("tar xvf $file $tarfile/application $tarfile/application_detail $tarfile/application_device_type $tarfile/genre_application -C /var/www/vhosts/httpdocs/fred"); How can I have it...

how to get results from exec() in python 3.1?

how to get results from exec() in python 3.1? #!/usr/bin/python import socket sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) host = socket.gethostname() port = 1234 sock.bind((host,port)) ret_str = "executed" while True: cmd, addr = sock.recvfrom(1024) if len(cmd) > 0: print("Received ", cmd, " command from "...

Scope of #TempTables limited to an EXEC statement?

By trying this use master go select * into #TempTable from sys.all_views select * from #TempTable drop table #TempTable exec(' select * into #TempTable2 from sys.all_views ') /* This will give error: */ select * from #TempTable2 I realized that #TempTable2 is not accessible... so using the select into #TempTable syntax is used in...

How to get PID from PHP function exec() in Windows?

I have always used: $pid = exec("/usr/local/bin/php file.php $args > /dev/null & echo \$!"); But I am using an XP virtual machine to develop a web app and I have no idea how to get the pid in windows. I tried this on a cmd: C:\\wamp\\bin\\php\\php5.2.9-2\\php.exe "file.php args" > NUL & echo $! And it gets the file executed, but t...

What can cause exec to fail? What happens next?

What are the reasons that an exec (execl,execlp, etc.) can fail? If you make a call to exec and it returns, are there any best practices other than just panicking and calling exit? ...

How to split a variable in two args with exec in TCL ?

Hello, I want to create a simple Console in Tcl/Tk I have two problems. First changing every * with a [glob *] but also, when my entry contains "ls -a" it doesn't understand that ls is the command and -a the first arg. How can I manage to do that ? Thanks proc execute {} { # ajoute le contenu de .add_frame.add_entry set valu...

Getting processes to use a particular shell

I have a process monitor script, procer, that runs as root and launches child processes and then chroots them to become my user and drop priviledges. This all works nicely. The problem I am having though is that I prefer to use tcsh rather than bash for normal day to day command line activities (in Snow Leopard), but the aforementioned (...