FAQ Database Discussion Community


Space character ignored in the linux exec file

linux,shell,exec
I was trying to run the following script DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" echo ${DIR} source ${DIR}/envcov.sh On echo, the output was /Users/John/Desktop/Test/Test Banking/XcodeCoverage When the execution reaches source ${DIR}/envcov.sh I get the following error generated ./getcov: line 7: /Users/John/Desktop/Test/Test: No such file or directory The...

How to increase quality of image through imagemagick binary convert?

php,image,imagemagick,exec,imagemagick-convert
Hereby,I working in Image conversion using imageMagick binary convert. When i resize small image into large image and also increase quality of image. Here my sample code: $img = 'old_image.png'; $path1= 'new_img.png'; exec("convert $img -quality 100% -density 600 -resize 2480x3508 -depth 400 $path1"); When i used this command it working...

Using setattr() to convert strings to variables

python,string,variables,exec,setattr
I am creating a sigsum() function which takes the sum using an input equation and an input variable. Here's what I have so far: def sigsum(eqn, index, lower=0, upper=None, step=1): if type(step) is not int: raise TypeError('step must be an integer') elif step < 1: raise ValueError('step must be greater...

ActiveXObject run does not return (shell)

javascript,shell,exec,activex
I am running a shell script from a JavaScript environment using ActiveXObject. Everything works just fine if I do not include any parameters in the run function: var x = new ActiveXObject("WScript.Shell"); x.Run("%comspec% /K dir") alert("I am here!") According to the documentation, "The Run method also accepts a Boolean value...

PHP SSH2 exec “$”

php,ssh,exec
i am wondering how i can run command from GET in PHP... here is my code: <?php $msg = $_GET['msg']; echo "$msg test"; if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist"); if(!($con = ssh2_connect("ip", 22))){ echo "fail: unable to establish connection\n"; } else { // try to authenticate with username root, password...

Why doesn't execlp allow me to use a pipe?

c,unix,pipe,exec
#include <stdio.h> #include <unistd.h> main() { execlp("ls" , "ls", "-l", "|" , "sort", NULL); } What's going wrong? Please help. If I write this: execlp("ls" , "ls", "-l", NULL); then the result displays on screen and if I try this execlp("ls" , "ls", "-l", "|" , "sort", NULL); screen displays...

Passing int using char pointer in C

c,exec,ipc
I'm trying to figure out how to pass an int using a char pointer. It fails once the int value is too large for the char. This is what I'm trying to figure out: char *args[5]; int i = 20; /*some other code/assignments*/ args[2] = (char *)&i; execv(path, args); How...

Java Invalid escape sequences

java,command,exec,command-window
I have this error : "Invalid escape sequences (valid ones are \b \t ..." in my code Java. I make in my code.java : ... r.exec("cmd /c D:\Doc and Settings\USER\Bureau\Apps-Two.loc.nal"); ... The problem is the escapes. How resolve this problem ? Thank you...

Creating non blocking pipes to child that does not block and can be reused

c++,pipe,exec,fork
I am trying to create a inter process communication bus using pipes. I can send messages to the client, and i can receive messages at the client. I also tried to create another pipe which goes the other way, child-> parent. However I need this communication to be non blocking...

real-time TCL exec output

tcl,try-catch,exec
I have the following scenario: if { [catch { exec echo calling a BIG script } exec_msg] } { puts "NOK" puts "output of the BIG script: $exec_msg" } else { puts "OK" puts "output of the BIG script: $exec_msg" } Are there any solutions to print the $exec_msg in...

cant execute python script from php

php,python,linux,exec,shell-exec
here is my code in control.php:- <?php $output = shell_exec("/var/www/script.py"); ?> why i cant run the shell_exec() command when i run the php script..? it should call the script.py and execute the py script.. but, when i run the control.php script.. note that i tried to run a normal program...

Ant exec command argument dealing with multiple files

java,ant,less,exec
I am using ant exec command to implement the less utility to view the source code of a bunch of .java files. (I know that there are other ways to do this like using concat) So the call ant view works if I specify only one file: <target name="view"> <exec...

What is wrong with my execvp usage?

c,linux,exec,fgets,execvp
I'm writing a small shell to learn C. Now I want to execute custom commands but it is not working. $ ./a.out OS>ls 10357: executing ls failed to execute ls : (2: No such file or directory) I must not use system call to execute custom command, I should use...

Running several 'exec' in a ruby loop

ruby,ffmpeg,exec
I'm scanning a folder for audio files and converting them to mp3. Works great in RUBY. However, once the first transcoding is done, it stops the whole loop Here's a breakdown of my code process. def scanFolder # lots of code above to get folder list, check for incorrect files...

Bash variable substitution on find's output through exec

bash,find,exec,substitution,built-in
Is there any way to apply bash variable substitution on find's output? I know I've seen some one do it on stack overflow but I can't seem to find that particular post anymore. As an example, let's say I want to rename files *.png to *_copy.png. I know I can...

tsql - sp_executesql difference

sql-server,tsql,stored-procedures,exec,sp-executesql
I have a problem about the way of my orm tool execute procedures. This is how i execute: exec PostViewProc @Id='18767F6A-FF7A-47E9-AF09-6DB8A2F3B20E',@AuthorId='5455D9B9-B25A-41BD-BD2C-C9CBAE87D629' Returns 1 row as expected.. And this is how the orm tool generates it: exec sp_executesql N'EXEC [PostViewProc] @Id, @AuthorId', [email protected] uniqueidentifier,@AuthorId uniqueidentifier', @Id='18767F6A-FF7A-47E9-AF09-6DB8A2F3B20E',@AuthorId='5455D9B9-B25A-41BD-BD2C-C9CBAE87D629' Returns NOTHING! First one just...

Why are execv*() arguments inconsistent with execl*()?

c,exec,standards,argv
Why are the argv arguments for the execv*() family of functions char * const [] whereas the execl*() family of arg0...n args are const char *? Is this just a mistake in the standard, and it should be const char * const [] or is there a reason for the...

I'm confused how this execvp() is handled in this sample function which uses fork() to clone a process

c++,c,linux,exec,fork
I have the following function from a book titled "Advanced Linux Programming". int spawn (char* program, char** arg_list) { pid_t child_pid; /* Duplicate this process. */ child_pid = fork (); if (child_pid != 0) /* This is the parent process. */ return child_pid; else { /* Now execute PROGRAM, searching...

Runtime.getRuntime().exec() in loops

java,loops,ffmpeg,runtime,exec
I'm writing a little tool to create some thumbnails in java automatically. therefor I execute Runtime.getRuntime().exec(command); in a for-loop. Now my Problem is, that only the first thumbnail gets created. My code so far: public static void testFFMpeg(File videoFile) throws IOException { FFMpegWrapper wraper = new FFMpegWrapper(videoFile); int length =...

How to create an anonymous pipe between 2 child processes and know their pids (while not using files/named pipes)?

bash,exec,wait,pid
Please note that this questions was edited after a couple of comments I received. Initially I wanted to split my goal into smaller pieces to make it simpler (and perhaps expand my knowledge on various fronts), but it seems I went too far with the simplicity :). So, here I...

go exec with <(..) argument

go,exec
I'm trying to get the equivalent using exec diff <(echo "foo") <(echo "bar") which produces: 1c1 < foo --- > bar But when I try: cmd := exec.Command("diff", "<(echo foo)", "<(echo bar)") The output is: exit status 2 diff: <(echo foo): No such file or directory diff: <(echo bar): No...

Safe use exec with php

php,exec,shell-exec
How can I use safe exec with php I'm try to do command with exec like this : exec("ejabberdctl register ". $_POST['username'] ." ". $_POST['password']) In this command if any one use in password some thing like this & free -m && free -m ;free -m or 123456 & rm...

Cross server EXEC

sql,sql-server,exec,linked-server
I have a several linked servers, with mass of DB's and tons of views and tables. The database names are like random set of letters and numbers and does not make any sense for me. Need to find on which server is certain view. DECLARE @servers AS TABLE (srv_name NVARCHAR(300),...

shell script, for loop, does loop wait for execution of the command to iterate

bash,shell,for-loop,exec
I have a shell script with a for loop. Does loop wait for execution of the command in its body before iterating? Thanks in Advance Here is my code. Will the commands execute sequentially or parallel? for m in "${mode[@]}" do cmd="exec $perlExecutablePath $perlScriptFilePath --owner $j -rel $i -m $m"...

close(pipe[1]) after exec

c,pipe,exec
I got a pipe. int anotherPipe[2]; make(anotherPipe); Both of the following processes have access to this pipe. Process A: close(anotherPipe[0]); dup2(anotherPipe[1], 1); //redirect stdout to pipe execl("/usr/bin/who", "usr/bin/who", NULL); close(anotherPipe[1]); //this is never executed Process B: close(anotherPipe[1]); read(anotherPipe[0], stringbuffer, bytestoread); printf("%s\n", buffer); printf("checkpoint\n"); close(anotherPipe[0]); The "who" command's output from execl...

Confusion with dup2(), exec() and pipes

c,unix,pipe,exec,dup2
I have been struggling to understand the concept involving the commands dup2(), exec() and pipes in conjunction. The thing I am trying to achieve: Pipe the output of a program X to the input of a program Y. Something basic like who | sort with a parent and 2 children,...

Forked and executed program does not returns to console

c++,console,exec,fork
I took example program from Advanced Linux Programming site: /*********************************************************************** * Code listing from "Advanced Linux Programming," by CodeSourcery LLC * * Copyright (C) 2001 by New Riders Publishing * * See COPYRIGHT for license information. * ***********************************************************************/ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> /* Spawn a child...

Running a docker container inside another docker container?

node.js,unix,exec,docker,boot2docker
I'm trying to create a contained docker environment inside another contained docker environment and call it through NodeJS's exec function. I've read through the Docker docs and as far as I can see, this is achieved by passing the --privileged flag when starting a container. As I'm developing on a...

mysqldump command with java Runtime.getRuntime().exec(command) not generating dump

java,runtime,exec,mysqldump
i have tried with the following code snippet: Process p; String command="mysqldump -u'scmuser' -p'scm$123' --routines db_name > /home/ubuntu/wh_demo_db_reset.sql"; p = Runtime.getRuntime().exec(command); the dump file is not generated and not thrown any error. i am unable to predict the exact issue please help me. thanks in advance....

Is it possible to pass the parameter in php execution?

php,exec
Hi I am trying to run a C binary program in a php script. The name of the binary program is prog and it takes one or two parameters. In terminal this binary program runs fine with this command: prog param1 In a php sript, I am trying to run...

Preserving the content in valgrind's log files when using --trace-children and execl()

c,exec,valgrind
I am currently cleaning up an existing codebase, and ran across an issue involving valgrind that I'd like to fix as it causes useful information to go lost. Valgrind is called as such: /usr/bin/valgrind --leak-check=full -v --log-file=./log/valgrind/valgrind-%p.log --trace-children=yes ./myapp arg1 arg2 >&! $logfile The program in question is a server...

Call to a member function exec() on a non-object ERROR in PHP [duplicate]

php,mysql,exec
This question already has an answer here: Reference - What does this error mean in PHP? 28 answers function add_member($idmembers, $firstname, $lastname, $email, $phone, $level, $password) { global $db; $query = "INSERT INTO members (idmembers, first, last, email, phone, level, password) VALUES ($idmembers, '$firstname', '$lastname', '$email', '$phone', '$level', '$password')";...

Can't execute exec command (php / windows / ffmpeg)

php,windows,ffmpeg,exec,command-line-interface
I'm trying to run this command that does work in cli ffmpeg -i tmp1.flv -c:a copy -vf drawbox=:x=0:y=0:color=invert:t=2 output1.flv I was able to run only ffmpeg -version by php. $res = exec("C:\\wamp\\www\\ffmpeg\\bin\\ffmpeg.exe ffmpeg -version"); Location of tmp1.flv file: C:\wamp\www\tmp1.flv When I'm running $res = exec("chdir") => C:\wamp\www\ How can I...

Running a shell script from java code [duplicate]

java,exec
This question already has an answer here: How to run Unix shell script from java code? 9 answers I am almost dead trying to sort this out.. Can someone help... please? Below is the code: import java.io.*; import java.lang.Runtime; import java.util.*; public class WORKBRO { public static void main(String...

Gatling 2: concurrent request handling

asynchronous,concurrency,resources,exec,gatling
I have a question regarding the behavior of Gatling when using .exec in combination with .resources. The documentation describes the behavior very briefly: Allows to fetch resources in parallel in order to emulate the behaviour of a real web browser Let's consider the following, simple scenario: val scn = scenario("Test...

what happens when I exec() from a forked child in c

c,exec,fork
Suppose I have process foo and executable bar. foo calls fork() and now I have two, call them foo_parent and foo_child. foo_parent calls wait() foo_child calls execvp([stuff to run bar]); I don't quite understand what happens to foo_child/bar. Is foo_child overwritten in memory with bar? Is a new bar process...

Calling Python file from within PHP

php,python,windows,exec
I would like to call a Python file from within PHP. I've tried this : exec('C:\Python34\python.exe ./python/genereBonDeCommande.py'); But it doesn't work. In my Python file I've got this : fichier = open(repertoire+"C:/Program Files/EasyPHP-DevServer-14.1VC9/data/localweb/projects/Administration/bonsDeCommandes" + nom_fichier, "No13"); fichier.write('hello'); Then how can I call a Python file from within PHP?...

How to send a variable between two C programs

c,pipe,exec,fork,argument-passing
I have a C program, xyz.c which does some computations on a certain variable, say transferme. I want to transfer this variable/ pass this variable to another C program, say jkl.c. I have been trying to do the following: Fork the xyz.c and use execvp() to pass this transferme to...

Client/server: running “nano editor” command from client

c,client-server,exec,nano
I have a client/ server program written i c language, a client can send and receive .txt documents to the server, i wish to Open the file received to visualize it with command nano For example, inside the running process: Something like this: Exec( nano, "file-to-Open.txt") but i dont know...

PHP exec() function throws empty array values with apache, but CLI's are fine

php,arrays,exec
I have this: exec('lsblk -no "UUID" 2>&1', $result); print_r($result); in CLI mode, everything is fine, the output is: Array ( [0] => [1] => [2] => d5b31fcc-ba84-47bc-ab1e-7f71178c791f [3] => [4] => Dj0hJ3-c9C4-B1px-HIYW-DGwi-v9I9-eppfgL [5] => e266aff1-e6a7-444a-b9b3-2da2f9b71202 [6] => 3fc422ac-0cde-4b54-aab1-cac10d3d5f0b [7] => ) But from http, the output is: Array ( [0]...

Exec php tar command to backup website dynamically

php,linux,exec,tar
I'd like to backup my website using tar command and exec of php and I wrote a small script to do that but nothing happens... where I fault? I have php 5.6.5 and hosting linux that have exec enabled and tar command available... so I have all materials for writing...

Javascript exec returning null

javascript,regex,google-chrome-extension,null,exec
My problem is when I try and use exec on my string, console throws this error: Uncaught TypeError: Cannot read property '1' of null Here's my code: var regexes = { "bold": [/\[bold\](.*)\[\/bold\]/g,"<b>","</b>"], /*"italics": [[/\[italics\]/g,"<i>"],[/\[\/italics\]/g,"</i>"]], "underline": [[/\[underline\]/g,"<u>"],[/\[\/underline\]/g,"</u>"]], "spoiler": [[/\[spoiler\]/g,"<div class='spoilerEnhanced'>"],[/\[\/spoiler\]/g,"</div>"]], "strikethrough":...

Run exec() in PHP as a different Windows user?

php,windows,cordova,exec
I'm trying to create a Cordova project in a PHP script, using : $command = "cordova create test"; exec($command); This doesn't work because the cordova command (which is a NodeJS plugin) is only available to the normal Windows user, and not the local system account that runs the Apache service...

gdb debugging process after exec call

gdb,exec
I don't know how to debug after the process after calling execle. I've looked at other websites and some suggested using set fork-follow-mode child, which helped me get into the fork. However, after the fork, I exit into the main function and never get into the program I am exec'ing....

Slimerjs with exec linux centos 6

php,linux,exec,slimerjs
I just installed Slimerjs and no results on the web. the slimerjs is found and commands like -help etc output like they should: exec('/usr/bin/slimerjs -help'.' 2>&1',$out,$ret); but this line does not work exec('/usr/bin/slimerjs /var/www/html/capture.js'.' 2>&1',$out,$ret); var_dump($ret, $out); outputs only int(1); and nothing more. no errors in logs, it does not...

PHP exec() nohup with redirect

php,exec,stdout,stderr,nohup
I am trying to execute a command with exec() and redirecting stdout and stderr to a file. exec("nohup python main.py -i 1 > /var/scripts/logs/1_out.log 2>&1 &"); It will create the file but it wont print anything to it. If I run the command in a terminal everything write without a...

nodejs 'exec' command doesn't execute 'sed' command properly

javascript,node.js,sed,exec
I have a file where I want to scan it, find the character '{' and create a new line, then add an IP on the new line and add a semi-cologne to the end of the line, then write to a config file. I can accomplish this with the following...

What happens to memory passed in arguments to exec*() family of functions?

c++,memory,exec
I understand that when calling exec*() the memory of the old process is completely replaced with the new program. However, what about the memory of the arguments such as argv? If I have code like this, is it safe to use memory from C++ data structures such as std::string or...

Make script in c++ for php

php,c++,exec,exe
I am making a website and PHP isn't poerfull enough for me, so i decided to use C++ also. I have made EXE file that do what is supposed to do, but I don't know how I can get the output in php, I cout the output and I thought...

Run eval `ssh-agent -s` gives errors

ssh,exec,puppet,puppetlabs-apache
Trying to run the command eval `ssh-agent -s with the command option puppet which gives me these error: exec { 'eval' : command => "eval `ssh-agent -s`", } Gives me this error: Error: Validation of Exec[eval] failed: 'eval `ssh-agent -s`' is not qualified and no path was specified. Please qualify...

Extra empty string when parsing string into arguments

c,parsing,exec
I'm trying to use the following parsing function I found online: void parse(char *line, char **argv) { while (*line != '\0') { /* if not the end of line */ while (*line == ' ' || *line == '\t' || *line == '\n') *line++ = '\0'; /* replace white spaces...

Exec after forking a process doesn't return the result before the program finishes

c++,c,pipe,exec,fork
I'm trying to make a program that forks once and while the parent waits for the child terminates, this child forks again and then executes two execs. There is a Pipe on the program and I've checked the return values of every dup2() and pipe() on the program -just omitted...

Running multiple exec commands and waiting to finish before continuing

background,tcl,exec,tk
I know I ask a lot of questions and I know there is a lot on here about this exactly what I am trying to do but I have not been able to get it to work in my script nor figure out why it does not let me do...

difference between docker attach and docker exec

docker,exec
Both will be able to execute commands in container. Both could detach the container. So what is the real difference between docker exec and docker attach?...

How to put arguments in a function at run time?

c++,linux,runtime,exec,argument-passing
So I am using execlp in my c++ program. execlp is of the form " int execlp(const char *file, const char *arg0,...,const char *argn)" meaning that it can take arbitrary amount of arguments. I just want to know that is there a way I can put arguments inside this function...

Gradle Exec : Why it is not running in configuration phase?

gradle,exec,mkdir
Here is my: build.gradle task makeDirectoryStructure(type:Exec){ description 'Creates directory structure .' commandLine 'mkdir' args '-p' ,'top_dir/sub_dir_1/sub_dir_2' println "This line is printed in configuration phase." } Now, since I haven't used '<<' or< 'doFirst/doLast', I expect mkdir to be executed in configuration phase i.e. whenever the build script is compiled. For...

Passing an instance of DirectoryIterator to another script via exec() is not working as expected

php,file,iterator,exec
I have a page that is executing a script for each file in a directory: $dir = new DirectoryIterator('/var/www/OCR3/upload_pending/'); foreach ($dir as $fileinfo) { exec("php manual_doc_proccessor.php $fileinfo"); echo "php manual_doc_proccessor.php $fileinfo" . " Sent for proccessing <BR>"; } Going to this script: $fileinfo = $argv[1]; if (!$fileinfo->isDot()) { print_r($fileinfo->getFilename()) ....

python forked processes not executing with os.execlp

python,osx,exec,forking
I've got this simple python script that ought to fork new processes and then have each execute a command using os.execlp, but the execution only occurs once. I'm curious if there's a timing issue going on that is preventing the additional forks from executing: import os for n in range(5):...

php exec inside exec / nested exec

php,apache,permissions,exec
If I'm already running code in a background by exec and inside it I call for another exec. Is it possible ? If so, does it need special permissions ? The error I have (and I suspect nested exec in it): exec() has been disabled for security reasons Regular exec...

using the find function and the exec flag

bash,find,exec
This is noob question: I'm trying to run the following script that I found online: find <file name> -type f -exec cat {} for some reason I'm getting an find: missing argument to '-exec' error. What am I doing wrong?...

Pass complete code to phantomjs

go,phantomjs,exec
I'm writing a service in Go and I'm using phantomJS to generate an image from a given url. From my Go program, I'm using Exec to start the phantomJS binary. This works fine, but now I'm looking for a way to pass the complete code, together with the call which...

php script in wamp giving error “not recognized as an internal or external command”

php,wamp,exec
<html> <body> <h2>xxxxxx!</h2> <script language="php"> $score = array(); exec("D:\Users\Owner\Documents\a2 2>&1 D:\Users\Owner\Documents\212.wav D:\Users\Owner\Documents\StartUp\23sw1.wav", $score); #echo "<h3>Score </h3>\n"; echo "<br />xxxxxxx: $score[0]\n"; </script> </body> </html> Error message: 'D:\Users\Owner\Documents\a2' is not recognized as an internal or external command, ...

Receiving error code during output redirection using execvp

c,exec,fopen,io-redirection,dup2
I am trying to redirect the output from ls to a file, in a shell I created in C. I type in: ls > junk and what I get out is: ls: cannot access >: No such file or directory Then if I use CTRL-D to exit the shell it...

Is a Command injection possible in the arg parameter of execve

c,exec
My program uses excve to run a ls, and the second argument is filled by the user : char * envp[1] = { 0 }; execve(my_command, user_input, envp); Is it possible for a user to inject a command in the user_input parameter even though it is considered as an argument?...

execl not running programming

c++,c,process,exec
I have the following two simple programs: bye.cc #include <iostream> int main() { std::cout << "Bye bye bye world" << std::endl; } hello.cc #include <cstdlib> #include <unistd.h> #include <sys/wait.h> #include <iostream> using namespace std; int main() { int status; cout << "Hello world" << endl; int pid = fork(); if...

Multiple sequential exec tasks in a single bash script

php,bash,exec,avconv
I'm trying to run the following two tasks in a bash script being triggered from a php script. Both of these are executing correctly when I comment out the other so it's obviously the way I've incorrectly laid out the complete job. They should be run sequentially, not in parallel,...