exec

PHP exec() and spaces in paths

扶醉桌前 提交于 2019-12-30 03:57:07
问题 I'm executing the following in a PHP application: $source = '/home/user/file.ext'; $output_dir = $this->setOutputString(); chdir('/home/ben/xc/phplib/bgwatcher-2011a/a01/'); exec('php bin/createjob.php $source $output_dir', $output); return $output[0]; The problem is this: I have control over $source , but not $output_dir , which is a legacy Windows filesystem, and there are spaces in the path. An example $output_dir is: /home/vol1/district id/store id/this_is_the_file.html When inserting the

Java: wait for exec process till it exits

寵の児 提交于 2019-12-30 03:13:13
问题 I am running a java program in Windows that collects log from Windows events. A .csv file is created on which certain operations are to be performed. The commands are execed and piped. How can I cause my Java program to wait until the process is finished? Here is the code snippet I am using: Runtime commandPrompt = Runtime.getRuntime(); try { Process powershell = commandPrompt.exec("powershell -Command \"get-winevent -FilterHashTable @{ logname = 'Microsoft-Windows-PrintService/Operational'

Compile PyPy to Exe

 ̄綄美尐妖づ 提交于 2019-12-30 01:35:10
问题 I know how to compile CPython file to exe using cx_freeze but is it possible to compile a simple program using PyPy to Exe ? 回答1: There is no ready-made way or tutorial on how to do create an EXE from a program using the PyPy interpreter, as far as i know. And it's not exactly trivial to get things going, i am afraid. In principle, there are two ways to consider for using PyPy's translations to get a EXE file, either using the PyPy interpreter or writing your own RPython program (The PyPy

SQL Server exec keyword

♀尐吖头ヾ 提交于 2019-12-29 08:51:30
问题 What is the role of exec keyword in T-SQL? I tried EXEC sp_rename 'mytable.foo', 'bar', 'column'; /* and */ sp_rename 'mytable.foo', 'bar', 'column'; Both commands produced seemingly same result. 回答1: The EXEC keyword tells SQL that you want to run a stored procedure, function or character string. Syntax can be found here: https://msdn.microsoft.com/en-us/library/ms188332.aspx EXEC is essential for using transact SQL, when you want to built a SQL statement dynamically. Common practice for

Running exec inside function

房东的猫 提交于 2019-12-29 07:59:11
问题 How can you use the python exec keyword inside functions? 回答1: It's going to damage your function's performance, as well as its maintainability, but if you really want to make your own code so much worse, Python gives you "enough rope to shoot yourself in the foot" (;-): >>> def horror(): ... exec "x=23" ... return x ... >>> print horror() 23 A tad less horrible, of course, would be to exec in a specific dict: >>> def better(): ... d = {} ... exec "x=23" in d ... return d['x'] ... >>> print

Creating a PHP Online Grading System on Linux: exec Behavior, Process IDs, and grep

丶灬走出姿态 提交于 2019-12-29 07:14:22
问题 Background I am writing a simple online judge (a code grading system) using PHP and MySQL. It takes submitted codes in C++ and Java, compiles them, and tests them. This is Apache running PHP 5.2 on an old version of Ubuntu. What I am currently doing I have a php program that loops infinitely, calling another php program by //for(infinity) exec("php -f grade.php"); //... every tenth of a second. Let's call the first one looper.php and the second one grade.php . (Checkpoint: grade.php should

I need execute a command line in a Visual Basic Script

醉酒当歌 提交于 2019-12-29 05:27:26
问题 I need to execute the command "ver" in my vbs to see the version of my Operating System, and i don't know how make it. I tried this, but dont work: Function ExecuteWithTerminalOutput(cmd) Set shell = WScript.CreateObject("WScript.Shell") Set Exec = shell.Exec("ver") End Function 回答1: Try something like this: Dim objShell Set objShell = WScript.CreateObject ("WScript.shell") objShell.run "cmd /c ver" Set objShell = Nothing EDIT: Well then you can redirect output to a file and then read the

How to run a Python file not in directory from another Python file?

痞子三分冷 提交于 2019-12-28 22:42:06
问题 Let's say I have a file foo.py, and within the file I want to execute a file bar.py. But, bar.py isn't in the same directory as foo.py, it's in a subdirectory call baz. Will execfile work? What about os.system ? 回答1: Just add an empty __init__.py file to signal baz is a module and, from foo.py do: from baz import bar Unless, of course, you have a good reason not to make baz into a module (and use execfile). 回答2: import sys, change "sys.path" by appending the path during run time,then import

Grab results from a php exec() while the command is still running?

▼魔方 西西 提交于 2019-12-28 16:25:50
问题 When I run an exec from PHP like so: $result = exec('command'); The results from this will be stored in $result . But in my current case, my command can take a few minutes and outputs results as it is running. Is there a way I can get output while it is running? I know that the passthru method will output the results to be browser, but I actually want it directly. 回答1: You should take a look at proc_open After making the output stream non-blocking (with stream_set_blocking ), you can read

Maven and Exec: forking a process?

你说的曾经没有我的故事 提交于 2019-12-28 06:41:49
问题 I'm trying to use Maven to start an application prior to running some integration tests on it. I'm on Windows. My Maven plugin configuration looks like this: <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.1</version> <executions> <execution> <id>start-my-application</id> <phase>pre-integration-test</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>start_application.bat</executable> <workingDirectory>./path/to