exec

stdin, stdout and stderr are shared between?

做~自己de王妃 提交于 2020-01-02 06:09:10
问题 I am trying to understand the behavior of the three streams - stdout , stdin and stderr . I couldn't get the answer from any textbook, so I came here. I know that these three are stored in file descriptor table with file descriptors 0 (stdin), 1 (stdout) and 2 (stderr). I am also aware that these are not merely file descriptors but I/O streams which can be redirected. Ok, so how about sharing? Consider the three cases: When a fork() is called : The child process and parent process shares file

Run server-side js from php through exec()

≯℡__Kan透↙ 提交于 2020-01-01 18:57:30
问题 I have a site running on Apache/PHP, and as a matter of performance, I wrote a javascript to do a specific task. I have installed node.js on server, in order to run this javascript. When I call the script from the command line, it works fine. See the command below: > node myscript.js But I need it to run from a php page, and I am trying to do this by calling the exec() PHP function, like this: <?php exec('node myscript.js >/dev/null/ 2>&1 &'); ?> ...but it's not working. Am I doing something

Java - Run Excel using runtime.getRuntime().exec

大兔子大兔子 提交于 2020-01-01 15:03:35
问题 try { Runtime.getRuntime().exec("excel C:\\file.xls"); } catch (IOException ex) { System.out.println(ex); } Doesn't work. I have to put the full path of excel.exe in order to work. How can I make it generic (For any Excel Folders/Versions)? When I run the same line from OS with Windows Run (Start --> Run) it works. Is there a code in Java to simulate Windows' Run command? 回答1: Why don't you try with the Desktop class (api doc here) introduced in JDK6 that has the method public void open(File

Can't execute java program with php exec function

梦想的初衷 提交于 2020-01-01 11:44:13
问题 I'm trying to execute a java program to sign a pdf file with php exec function but doesn't work: exec('java -jar PROGRAM.jar -n -t ORIGIN.pdf -o DESTINY.pdf -s CERTIFICATE -p PASSWORD', $output, $return); When I execute it, the $output is an empty array and $return is an int(1), but if I run: java -jar PROGRAM.jar -n -t ORIGIN.pdf -o DESTINY.pdf -s CERTIFICATE -p PASSWORD In command line it works. Can anyone help me? Thank you. 回答1: @Treffynnon is right. The difference between executing

exec always returns -1 (or 127)

霸气de小男生 提交于 2020-01-01 08:35:09
问题 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 wherever the command finished successfully, and on every other server tested this works as expected:) Anyone ever hit a situation like this? edit: <?php $command = "asd";

How to use QFileDialog options and retrieve saveFileName?

喜你入骨 提交于 2019-12-31 22:37:28
问题 I'm trying to use a QFileDialog to prompt a user to provide a filename and location to save a text file at. I played around with the QtGui.QFileDialog.getSaveFileName, but I was interested in using some of the options, like setting the default suffix, and enabling the Detail view of the save file dialog, which, from what I could tell, isn't possible to do, using the getSaveFileName alone. Whenever I set those, the getSaveFileName dialog just ignored them. So, I ended up with something like

How to enable exec() in php?

笑着哭i 提交于 2019-12-31 05:32:07
问题 My exec function is not enabled, I need this function for one of my files. I would like to enable it inside my of php code if it's possible without having to make changes inside of my php.ini file. Thank you 回答1: The setting you need to change is disable_functions and as per the description in the manual: This directive must be set in php.ini For example, you cannot set this in httpd.conf. So unfortunately, the answer to your question is no. With that said, there's usually a workaround so

Android: ffmpeg with filenames containing spaces

烂漫一生 提交于 2019-12-31 05:30:13
问题 I want to execute ffmpeg from an Android app, very much as described here: Using FFmpeg with Android-NDK. Executing the following commands work fine: Process p = Runtime.getRuntime().exec("/data/data/yourpackagename/ffmpeg -i infile.mp4 outfile.mp4"); or Process p = Runtime.getRuntime().exec(new String[]{"/data/data/yourpackagename/ffmpeg", "-i", "infile.mp4", "outfile.mp4"); But when the input or output filenames contain spaces ffmpeg fails with a "File not found" error: Process p = Runtime

Eval/Exec with assigning variable - Python

佐手、 提交于 2019-12-31 05:14:11
问题 The below piece of code is aimed at converting a factorial into its products. E.g. "4!" --> "(4*3*2*1)" . This code does not work due to the line exec(codeToRun) . However, if I instead put the value of codeToRun in place of exec(codeToRun) then it works perfectly so why doesn't exec work? Doesn't work ↓ def checkSpecialChars(char, stringToCheck, codeToRun): while char in stringToCheck: currentString="" for i in range(len(stringToCheck)): if stringToCheck[i]==char: try: eval(codeToRun) except

Learning pipes, exec, fork, and trying to chain three processes together

倖福魔咒の 提交于 2019-12-31 04:05:09
问题 I'm learning to use pipes and following along with this code on pipes. The program makes two child processes using fork. The first child runs 'ls' command and outputs to pipe1. The second reads from pipe1 runs 'wc' and outputs to stdout. I'm just trying to add a third process in the middle that reads from pipe1 and outputs to pipe2. Basically what I'm trying to do ls | cat | wc -l What I'm trying to do: (ls)stdout -> pipe1 -> stdin(cat)stdout-> stdin(wc -l) -> stdout Nothing ever prints to