exec

Command line character encoding from PHP's exec()

I'm trying to pass UTF-8 text as an argument to a command line program using php's exec function and have been having problems. I suspect it's due to character encoding issues. When I call locale charmap from the command line, I get: UTF-8. But when I do: <?php echo exec('locale charmap'); ?> I get ANSI_X3.4-1968 How can I change...

python 2.7 / exec / what is wrong?

Hello, I have this code which runs fine in Python 2.5 but not in 2.7: import sys import traceback try: from io import StringIO except: from StringIO import StringIO def CaptureExec(stmt): oldio = (sys.stdin, sys.stdout, sys.stderr) sio = StringIO() sys.stdout = sys.stderr = sio try: exec(stmt, globals()...

PHP / Apache - Refreshing screen while exec'd script is running

Hello, One page on my web site is a PHP script that uses exec() to launch a separate PHP script which generates a PDF document. The PDF may take 30 seconds to generate. When I hit the refresh button during this process, I am finding inconsistent behavior. On both my Mac and Windows local dev machines, refreshing the page will hang Ap...

PHP exec $PATH variable missing elements

When I echo $PATH on my command line, it returns /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/MAMP/Library/bin:/usr/local/git/bin:/usr/X11/bin When I execute this php code exec('echo $PATH; whoami; less /etc/paths; 2>&1') I get string 'echo $PATH; whoami; less /etc/paths; 2>&1' (length=56) array 0 =>...

simple shell using execlp goes weirdly

I am reading GNU/Linux application programming the 2nd edition,you can reach what am reading from here.After I write the code similar to his,but it work strangely: $ ./shell ./shell>>quit $ ./shell ./shell>>date Sun Aug 8 21:19:37 CST 2010 ./shell>>quit $ ./shell ./shell>>abc execlp failed: No such file or directory ./shell>>quit ./she...

how to exec exe file and quite it successfully in ruby

For now ,i want to run exe file from my disk, after finished to install that exe file, will show a popup message which tell user that already finished install exe file, but i do not konw how to close the popup message. Does anyone know how to do that ?? thank you very much ...

What exactly does this line do, and how does it do it? open my $fh_echo, '-|' or exec "$sshstr \"$str\""

Here is this line in perl: open my $fh_echo, '-|' or exec "$sshstr \"$str\""; Basically it exec's $sshstr and then the output goes into $fh_echo, somehow. I am curious as to the mechanisms that go behind this operation. Can someone explain what the '-|' means? Also how does this loads the output into $fh_echo? Does it output it littl...

passing integer arguments when using execve

Hello I am a beginner at programming using system calls in C. I am trying to use the execve call in one of my programs. I have to pass an integer as an argument to the program that is being invoked through execve. However, reading on the internet and seeing sample code, I can see that we can pass only strings as arguments. So, I tried c...

Calling code in a string without exec/eval, python

I have this code that executes when a player attempts to eat something: def eat(target='object'): global current_room global locations global inventory if target in inventory: items[target]['on_eat'] #This is showing no results. else: print 'You have no ' + target + ' to eat.' and this code for item...

exec always returns -1

Hello, I'm using php 5.2.9 on a production server, and it seems that the exec() function behaves "non-standard". If i run exec("ls", $output, $return_var) then $output will contain the list of files in the current folder as expected, but $return_var will be set to -1 instead of 0, as expected. I'm using the $return_var to determine wher...

Trying compile a C Code with PHP

I have a file named gcc.exe and I have a php page... I want to use: gcc test.c And, if there's some compilation error, I want to show it on the php page... But I can't. What happens is: If the file is correct, it generates the .exe file, but if it's wrong, nothing happens. What I want here, again, is to show all errors. Anyone has an...

About exec() function and time

I'll show some code, first: echo exec("compile\\save.exe Untitled.c tmpUntitled.c"); I have a program, named save.exe and i want to know if it already stopped? If stopped, ok... Do something... If not, may be an error, or a loop... Now: I want to build same way to control the time that program use, and put a limit (time limit exceed,...

Execute "less" from command-line PHP w/ Scrolling

I want to execute less and similar programs from the command-line in PHP. I have tried the usual suspects (exec, shell_exec, passthru, etc), and while many of them can dump the file to the screen, the process is terminated before I can make use of it. If I wanted cat, I'd use it. How do I execute a program in this fashion? ...

Clean up QThread after calling quit()

I have a problem. If I call Abort(), run function will return without complexMath instance have enough time to do clean up. What i want is, after calling Abort(), complexMath instance have enough time to shutdown itself, clearing all pending signal and slot(inside complexMath, it also have it own signal and slots) before it return. vo...

php chown exec() question!

Hi people, I need to write an exec to change owner on some folders on my webserver. This is what I am working with. exec('cd /xxxxx/xxxxxx/public_html/ && chown user.user * -R', $out); Got to be honest Apache is not my bag so kind of stumbling in the dark. Basically I need to change all directories to user and not 99 as they currentl...

Why is this free failing when calling execvp?

First of all, I'm running in C on a Windows 32 bit system compiled with Visual Studio 2008. I'm running in debug mode. My code essentially is this: execvp( *argv, argv ); Where argv has three entries and looks like this: argv[0] = "pgserv"; argv[1] = "pgserv"; argv[2] = NULL; Yes, I am aware that that calls the pgserv application ...

why cant I use log files in java runtime

I have (in java), rt.exec("qq.exe -i ..(some other parameters) > qq.log");//*1 when I run qq.exe -i ..(some other parameters) > qq.log in terminal It works fine and keeps the qq.log file correctly. However using rt.exec (*1) doesnt work. " > qq.log" part causes problem. When I delete that part rt.exec (*1) works but I cant have qq.l...

tcl exec reads stdout first then stderr?

Hi, I found tcl exec command returns string from stdout first then stderr. For example, my following "test script" generates messages in this order: puts "test started" puts stderr "some non-fatal error goes to stderr" puts "test passed" Then I execute the script like this: set ret [ catch { exec sh -c $cmd } msg ] and what I get...

Java Runtime.exec running java problem

Hi, I have a simple server application, which I would like to run in the background. The following line works for me: Runtime.getRuntime().exec("cmd /c start java -jar ..\\server\\server.jar -Dlog4j.configuration=file:src\\test\\resources\\log4j.properties -filename src\\test\\resources\\server.properties"); But it displays the cmd wi...

php exec output being trimmed

Hi to all again, I have again another trouble with using exec in php my os is suse linux and I am using php 5.1.2 Somehow my output is being trimmed when i use exec() in linux ~ -> ps -ef | grep java root 3548 1 0 Aug05 ? 00:00:01 /usr/java/jdk1.5.0_13//bin/java -server -Djava.awt.headless=true -Xms512m -Xmx512m -XX...