exec

Is PHP exec safe?

I am trying to get exec working on a Windows server and receiving the error message "unable to fork". After googling the issue a bit, it seems the recommended fix is to give the IUSR account READ and EXECUTE permissions to c:\Windows\System32\cmd.exe. But that has got be a major security hole right? Is it safe? Is there another way to e...

using Runtime.exec() in Java

What do you have to do in Java to get the Runtime.exec() to run a program that is on the path? I'm trying to run gpsbabel which I have put into the path (/usr/local/bin). public class GpxLib { public static void main(String[] args) { try { Runtime r = Runtime.getRuntime(); Process p = r.exec("gpsbabel -i garmi...

Protecting executable from being patched

My logic of APT (Anti-Paching Technology) is as follows... 1) Store on the MSSQL server the md5 hash of the executable for protection. 2) Perform an md5 comparison (within my application startup) the hash found on the server, with the executable itself. 3) If comparison fails exit application silently. And all these above before it i...

how to execute an external program from within php without waiting for finishing execution

hi all, i want to execute an external program from within php. but i dont want that php wait for the program to execute. when i use exec function it wait for the program till it finish. ...

Java runtime.exe() Error launching browser : error accessing current directory

I have been trying to launch browser from a java app on Linux. When this app is run for the first time browser don't get opened. The error log shows : shell-init: cannot get current directory getcwd : no such file or directory. After this if u restart everything falls into place and browser opens fine. I have tried many things like cha...

Piping SQL to mysql via -find -exec

I cannot for the life of me get this. Example of fails, the last line of which adds in sed, which is the ultimate goal: find -maxdepth 1 -name "*.sql" -exec "mysql -D ootp < {}" \; find -maxdepth 1 -name "*.sql" -exec "mysql -D ootp << {}" \; find . -maxdepth 1 -name \"*.sql\" -exec /usr/bin/mysql -D ootp << sed -e 's/ , );/1,1);/g' {} ...

Good way to send result of 'uname -a' to a stream?

Hello, What is a good way to call 'uname -a' from a C++ program and send the results to a stream? I looked at system() and exec(), but they do not seem to give access to the stdout of the call. Thanks. -William ...

Invoking an external process with a different user in java

We have a java application running as a windows service. A particular functionality needs to execute a binary but with a different user then which started the application. Is there any way by which we can invoke an exe with 'Run as a different user' style. I checked API of ProcessBuilder but didn't found anything related to user. Is th...

execl pipe without dup

Hello everyone, I am trying to execute a program from a parent using execl. I do the normal pipe setup and fork. Here is the trick... I need my children (there can be an arbitrary number of children) to all communicate with the parent. Program "A" (parent) creates pipe forks and execl into "B" (child). In the main() function of prog...

Why does ant.bat not return an error status when run programmatically?

When I run ant from the command-line, if I get a failure, I get a non-zero exit status ($? on UNIX, %ERRORLEVEL% on Windows). But we have a Java program which is running ant (through ProcessBuilder), and when ant fails, on Windows we cannot get the exit status. I just verified this with this simple ant test file: <project name="x" def...

PHP exec() hangs, Error 500

So, my plan is to make small thumbnails of URL's with PHP and IECapt. IECapt works well, a nice command line tool, gets the full sized image of specified URL in 1 to 4 seconds. But my problem is to execute it trough PHP. This is the code I've trying to get working: exec('IECapt.exe ' . escapeshellarg($URL) . ' ' . escapeshellarg($Filen...

How does exec work with locals?

I thought this would print 3, but it prints 1: def f(): a = 1 exec("a = 3") print(a) ...

Unix programming... fork() & execv() help... C Programming

I'm writing my own unix terminal and I'm running into a problem executing commands: First I take the user input and store it into a buffer, then I separate the words and store them into my argv[] array. i.e command is "firefox" to launch firefox which is stored in argv[0] How do I launch the command? This is what I'm trying to do, but...

How to do command line from PHP script

I need to write a script that will give users info on a given Unix account (the same Unix server that the script lives on). Mostly thing kinds of things that are in the passwd file or available via finger. PHP is in safe-mode, so I can't access the passwd file via something built into php like file_get_contents(). Also, because it's in ...

Executing "echo $PATH" from a c program?

I am trying to display, set & modify PATH environment variable from a C program. I am doing something like this:- char *cmd[] = { "echo", "$PATH", (char *)0 }; if (execlp("echo", *cmd) == -1) But I am not getting the results. ...

Can we start a background process using exec() giving & as an argument?

If not, how can we start a background process in C? ...

Problem with echo $PATH

I am working on bash shell When I type echo $PATH on $ prompt I get the value of path environment variable as /opt/bin:/usr/local/bin:/usr/bin:/bin:/usr/games I am creating my own shell and I want to print the path environment variable when user enters echo $PATH. How do I do that? ...

Performance: PHP and MS SQL Server: SQLCMD using Exec or Driver

Hello all, I am currrently making queries to my SQL Server using SQLCMD and I run this from PHPs exec() function. I was hoping to clarify that this isn't as efficient as the driver for SQL Server for PHP: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx. I am not sure if this is the same as http://us3.php.net/manual/en/book...

Trying to start VPNC from PHP exec()

I am trying to start my VPN connection (using VPNC) from PHP. I have to do it this way because it is closed remotely if there isn't activity so I can't just leave it running on the server. I am able to do it from the command line by typing: /usr/local/sbin/vpnc --natt-mode force-natt This works. It doesn't require any input from me...

PHP exec() return value for background process (linux)

Hello, Using PHP on Linux, I'd like to determine whether a shell command run using exec() was successfully executed. I'm using the return_var parameter to check for a successful return value of 0. This works fine until I need to do the same thing for a process that has to run in the background. For example, in the following command $...