Questions tagged [exec]

1

votes
2

answer
30

Views

C - Redirecting IO of Child Process

I am trying to redirect the IO of a child process (after fork()) into a file, and I can't figure out why it isn't working. Here's what I've done: if(fork() == 0){ execv(exe, (char*[]){ exe, '> temp.exe' }); ... And the executable runs, but it doesn't redirect to the file. I would appreciate it if an...
Omer Lubin
1

votes
1

answer
178

Views

node js: I to get the output of an (child) exec and set a variable to be retuned?

I have been searching for a truly example, but I could not find any. I m fully new to node js. I am setting up a service which gets passwords using a command line tool. The command line 'pw get key' returns the password associated with the key. The command line 'pw set key password' sets the passwor...
mariotti
1

votes
1

answer
209

Views

Move to Rails 5.1 Unexpected token: eof (undefined) in move to Production

I'm having problems moving a Rails app that I've updated from 4.x to 5.1 into production. Works fine in development, but when I use Capistrano to move to the production environment, I get the below. Note that every post of similar issues seems to have a syntax error in their code, and while it is p...
codenoob
1

votes
1

answer
146

Views

End the background process of php exec command

Is there a way to end this background process executed by this code? $process = exec('nohup java -jar '/selenium-server-standalone-3.8.0.jar -> /dev/null &'); I am simply running a jar file which is a server, I need to stop this server after some code is executed, is there a way to end it? something...
Cowgirl
1

votes
1

answer
77

Views

Launching an app from within main(). Specify path and filename together or separately?

From what I understand, the first two statements in the try block should have the same effect; launch chrome.exe, but the first one causes an IO exception because it can't find chrome.exe. Am I doing something wrong? import java.io.File; public class Program { public static void main( final String[]...
Frank Maibaum
1

votes
1

answer
225

Views

Check if specific php script is running in windows ,by script name

I am running PHP script form my API by running : shell_exec('php . php-file.php'); then in refresh, I want to call API to check if the process is still running I tried this: exec(tasklist 2>NUL' , $task_list); but in the task list, there is only php.exe How can I get the specific file name or som...
Tuz
1

votes
0

answer
79

Views

php perl script can not run using shell_exec

i am trying to execute perl script using php shell_excel function. but instead of printing output it ask to open perl file when i execute php script. i tried below $result = shell_exec('app.pl'); app.pl contains below script #!/usr/local/bin/perl $count = 0; while () { @w = split; $count++; for (...
amit nindroda
1

votes
0

answer
45

Views

Python - API / wrapper function design pattern

I'm implementing API which takes users' code and execute at my server. For instance, user submits the code as following push('item') then I want to execute this string code in the users's context, such as users_stack.push('item') What would be the design pattern and how do I convert user's code this...
Tim Park
1

votes
0

answer
26

Views

Apache ExectuorWatchDog hangs while writing to System.out/JtextArea

I am executing testng.xml(having 40 Testcases) from cmd shell using Apache.commons.exec.Executor in java with following code : public static void executeBatch(String folderLoc) throws Exception { try { String cmd_for_testng = 'java -cp ' + 'D:\\project\\libs\\*;D:\\project\\bin' + ' org.testng.TestN...
Anu Chawla
1

votes
0

answer
555

Views

PHP exec : Unable to fork

I am calling exec in PHP in a shared hosting environment and I am sometimes getting non null exit codes. I sometimes receive either a -1 exit code and following warning 'PHP warning: Warning: exec(): Unable to fork', either a 254 exit code with no PHP warning. I guess I am running out of some reso...
user2708647
1

votes
0

answer
76

Views

How to use tee or > within “screen” while also supplying the name of the screen to them?

I am trying to start a number of jobs in different screens from a shell script. Each job will read in a different value of a parameter from a premade input file and run a simulation based on that value, then tee or > the output to a differently named file. So in a do loop around all the jobs, job 40...
Chris Rollins
1

votes
2

answer
230

Views

Python Script Hangs When Called via PHP shell_exec()

I have a Python script that is called from PHP using shell_exec, all was working fine and the script came back to the PHP function after the Python script completed and everything was working as exepcted. Now I have changed the Python script to include a class one level up from it that creates a web...
llanato
1

votes
2

answer
86

Views

Java Runtime.getRuntime().exec different output format

I have a simple python program (hw1.py) as follows: x = int(input('Enter x value: ')) y = int(input('Enter y value: ')) print('x is ' + str(x)) print('y is ' + str(y)) print('Output is ' + str(x+y)) When I run it from terminal, I get following output as expected: Enter x value: 10 Enter y value: 20...
Inanc Arin
2

votes
2

answer
25

Views

Why exec() works differently when invoked inside of function and how to avoid it

I'm trying to declare two functions within exec statement in python. Let's call them f1() and f2(). I've found out that when exec is invoked inside of some function, then f2() has no visibility of f1(). However this doesn't happen when exec and function call are placed in global code. # Case 1: Wor...
Mikhail Yamkovy
1

votes
1

answer
61

Views

How do I pipe data into an executable from within a PHP script?

I have a binary that takes input from stdin that I use on the command line by piping file contents to it like cat query.sql | go-mysql-format, but how do I pipe a variable to the executable? Currently I have file_put_contents($File = '$_SERVER[DOCUMENT_ROOT]/tmp/' . uuid(), $MySQL); $o = shell_exec...
Brian Leishman
1

votes
1

answer
689

Views

curl with maven exec plugin not working because of “Can't handle single and double quotes in same argument”

To promote a build after successful deployment of an docker image of artifactory, we have to do a curl like this: curl -k -I -u usr:pw -X POST https://company.com/artifactory/api/docker... - H 'Content-Type: application/json' -d '{'targetRepo':'project-release','dockerRepository':'project/sample','t...
MemLeak
1

votes
1

answer
154

Views

How to process unicode characters (utf8) in shell command executed in php

I have dir function that I use to find all executables files and directories it have code like this: $EXEC = 'X'; $DIR = 'D'; $FILE = 'F'; // depend on GNU version of find (not tested on different versions) $cmd = 'find . -mindepth 1 -maxdepth 1 \\( -type f -executable -printf '. ''$EXEC%p\\0' \\)...
jcubic
1

votes
0

answer
83

Views

ssh2 php, output not display

I want to display my output of my js... ::php code:: my VPS display at exec the command but in web some output not display whats wrong with my script?? I will display all of my output (sorry for noob question) thanks hope you will help me :)
Hery Winarto
1

votes
1

answer
45

Views

Issue when executing shell script in php

I have developed one webpage using PHP . I need to run shell scripts through the php code. I was able to do the same via below method : shell_exec('cd shell_scripts;./ipCheck.sh'); ipCheck.sh is like below : SO_IP=$(lxc list SO-ub | awk 'FNR== 4 {print $6 }') b=10.12.130.2 echo 'The IP is $SO_IP ....
Pradip
1

votes
2

answer
70

Views

How to handle interactive commands using runtime.getRuntime?

I have to execute a command from Java program on Unix platform. I am using Runtime.getRuntime() for it. However, the problem is that my command is interactive and asks for certain parameters at runtime. For e.g., the command is createUser. It asks for userName as the runtime. bash-4.1$ createUser...
Sammi
1

votes
1

answer
296

Views

Calling curl command from Ruby's system method

I'm using curl command inside logstash exec plugin to post a message to a stride group. The plugin documentation stated that they were using ruby system method to execute the command, so I'm trying to run it in my ruby IRB. Escaping the double quotes with backslash character is giving error The requ...
Vizkrig
1

votes
0

answer
35

Views

Spawning separate windows for new processes with Apache Commons Exec?

I'm attempting to launch several batch files in their own windows using the Apache Commons Exec library, and although I'm able to launch them properly, I'm running into one small issue where the output from the JVMs being spawned are showing in the window for the original process. I need them to all...
Darin Beaudreau
1

votes
1

answer
501

Views

PHP shell_exec() executing in C:/xampp/htdocs and not in C:/xampp/htdocs/folder

I am trying to execute a file using shell_exec in PHP. However, whenever a .bat file is executed it's ran from cd C:/xampp/htdocs instead of a folder within that such as cd C:/xampp/htdocs/folder. Here's an example. shell_exec('c:\WINDOWS\system32\cmd.exe /c START c:/xampp/htdocs/TeenHost/mc/folder/...
1

votes
2

answer
44

Views

Nodejs Exec doesn't execute

I am working with Nodejs to create a tester module. So I need to use exec. This code work and is doing well: const { exec } = require('child_process'); var nb_test = 1 var return_array = [nb_test]; var finished = 0; var i = 0; while (i < nb_test) { var env = { 'NB_MALLOC': i.toString()}; console.lo...
Le Mayennais
1

votes
1

answer
29

Views

what function in Linux API implements execution of a script file with a shebang?

From https://unix.stackexchange.com/a/2910/674 ... the way shebang (#!) is typically implemented: The kernel opens the executable, and finds that it starts with #!. The kernel closes the executable and opens the interpreter instead. The kernel inserts the path to the script to the argument list (as...
Tim
1

votes
1

answer
41

Views

Asynchronous function with exec ruby

hi I have an error on running this asynchronous function, this asynchronous function makes a call to the ruby ​​file! Should I set the code so that the asynchronous function waits for the termination of the exec and base64.encode, how can I do? async function GenerazioneRapportino() { var encode...
riki
1

votes
0

answer
99

Views

Java Runtime.getRuntime() and Process Builder unable to execute perl script with arguments

I am trying to call a Perl script from a Java program using Runtime.getRuntime().exec(). The Perl script has multiple arguments. For example: abc.pl -dt 64 -dir C:\Projects\xyz -name pqr -args 'X24 X56' The Perl program is being executed but not receiving all the arguments. This causes the script to...
Parth Mahajan
1

votes
1

answer
686

Views

How to set both VM Params and Program args using exec-maven-plugin?

I am using exec-maven-plugin to run java app. I need to pass both JVM params and program arguments. I am setting JVM params like this: exec-maven-plugin 1.6.0 MyId java MyClass -XX:+UseG1GC -Xms2G -Xmx2G ... and run the program: mvn exec:[email protected] -Dexec.args='my...
Tatiana Didik
0

votes
1

answer
434

Views

Execute any bash command, get the results of stdout/stderr immediatly and use stdin

I would like to execute any bash command. I found Command::new but I'm unable to execute 'complex' commands such as ls ; sleep 1; ls. Moreover, even if I put this in a bash script, and execute it, I will only have the result at the end of the script (as it is explain in the process doc). I would lik...
x4rkz
1

votes
0

answer
94

Views

Tensorflow Module Not Found When Using shell_exec()

So I have gone through 3 different VMs of Ubunutu messing with things trying to get a shell_exec() command to work from PHP with Tensorflow. Tensorflow is installed and working properly I can use it all day from the command line. If I run python -V from the PHP file using shell_exec() its the same v...
Tyler
0

votes
1

answer
110

Views

linux ulimit with java does not work properly

I run code on linux ubuntu 17.10 public class TestExec { public static void main(String[] args) { try { Process p = Runtime.getRuntime().exec(new String[]{'/bin/sh', '-c', 'ulimit', '-n'}); BufferedReader in = new BufferedReader( new InputStreamReader(p.getInputStream())); String line = null; while...
Michal
1

votes
0

answer
46

Views

Execute bash commands via Java in Ubuntu

I have such command: top -bn1 | grep \'Cpu(s)\' | sed \'s/.*, *\\([0-9.]*\\)%* id.*/\\1/\' | awk '{print 100 - $1} I tried to run it with ProcessBuilder or Runtime, but I get nothing. Why?
sirsubbotin
1

votes
0

answer
61

Views

How is `open()` with `O_EXEC` different and related to `execve()`?

From APUE, open() has a flag option O_EXEC Open for execute only. However, I only see execve() is used in the examples that I have seen. So when is open() with O_EXEC used? How is that different and related to execve()?
Tim
1

votes
0

answer
37

Views

What happens to a process when it's overlayed with a new process in Windows

In Windows, the _spawn functions, documented here, are able to overlay a parent process with a child process when you pass the _P_OVERLAY flag. From the docs: Overlays a calling process with a new process, destroying the calling process The question is, what happens to the parent proccess when it's...
Mercalli
1

votes
2

answer
40

Views

How to avoid php parsing the whole php file and includes and make it only parse what will be used?

I read somewhere that php parses the whole .php file every time it is executed. Some solution was proposed in there (that was not opcache), but I lost the website and I couldn't find it. Now I have an enormous php website that has many long functions that are often used alone, and it's required that...
algo
1

votes
0

answer
35

Views

3rd Party Dependency Install - Issue

In my POM, I have maven-exec-plugin, which generates a Jar (say JarX). The same JarX I am installing to my local repo using install-plugin. Also my dependency list contains details for this jar to be used in build path. But while building the project, it fails while resolving JarX dependencies. Is...
ImLearning
1

votes
1

answer
58

Views

How can I download a file from a site that is protected with a username and password, using the Selenium framework?

I am trying to download a file from a site that is protected with a username and password, using Selenium. First, I got the href attribute from the download link: WebElement downloadLinkElement = htmlElement.findElement(By.xpath()); String url = downloadLinkElement.getAttribute('href'); Secondly, I...
Narcis Neacsu
1

votes
0

answer
47

Views

Why does _execv put processes in background on Windows?

Consider this wrapper: /* build using x86_64-w64-mingw32-gcc -o ping_wrapper.exe ping_wrapper.c */ #include #define REAL_EXECUTABLE 'C:\\Windows\\SysWOW64\\PING.EXE' int main(int const argc, char const * argv[]) { argv[0] = REAL_EXECUTABLE; _execv(REAL_EXECUTABLE, argv); abort(); } Now if I run C:\...
not-a-user
1

votes
0

answer
153

Views

python call with php: ImportError - no module named dbfread

I want to call a python-script with php which loads an dbf-file. In php I call the script: $command = escapeshellcmd('python getData.py'); $output = shell_exec($command); The python-script: #!/usr/bin/env python import sys reload(sys) sys.setdefaultencoding('utf8') sys.path.insert(6, '/home/pi/.loca...
HorstVonMorgen
1

votes
0

answer
29

Views

How to show progress when converting documents using libreoffice

When I convert documents using libreoffice on server. It takes a long time to process. I need to know progress to response to front end. But I don't find any info about progress of this conversion. I also try as below when converting doc to pdf: exec('soffice --headless --convert-to pdf $oriFile --o...
Sinh Ho

View additional questions