exec

Outputting exec() ping result progressively

有些话、适合烂在心里 提交于 2020-01-14 03:02:13
问题 I'm trying to write a function that pings a few hundred addresses and returns their values (milliseconds). So far I've achieved the initial idea which is to ping and get the result but the problem arises when using the same code for hundreds of addresses, the PHP page stalls until it either times out or reaches the last ping command. I would be glad if I could get some suggestions to output the results progressively, here is my current code: <?php // "for" loop added according to suggestion

PHP ffmpeg exec returns null

纵饮孤独 提交于 2020-01-13 11:05:15
问题 I'm trying to run ffmpeg through a PHP exec call, I've been debugging for a while and looked at lot of responses on here, but still not found any answers... My simplified call is: $cmd = 'ffmpeg 2>&1'; exec(escapeshellcmd($cmd), $stdout, $stderr); var_dump($stderr); var_dump($stdout); var_dump($cmd); exit; My output is $stderr = int(1) and $stdout = array(0) { } Also I tried shell_exec($cmd) which returns NULL . cmd.exe has permissions set for the IUSR account - e.g. I can run $cmd = 'dir'

How to make shell exec run in background while php continues

删除回忆录丶 提交于 2020-01-13 08:29:13
问题 I have ffmpeg doing a video conversion in a PHP file and it works as it should. The problem is it takes up to a minute for this to finish. I thought it might be easy to do but I can only get it to work in the background when I use just one command (eg single pass conversion without mp4box) like this exec("nohup " . $ffmpegPath . " -i " . $srcFile . " -f mp4 -vcodec libx264 -crf 27 -s " . $srcWidth . "x" . $srcHeight . " -an -r 20 " . $destFile . ".mp4 > /dev/null 2>&1 &"); The problem is I

kill users processes in linux with php

别说谁变了你拦得住时间么 提交于 2020-01-11 13:35:09
问题 I am trying to write a php script to kill users in a redhat machine. I know it is possible (and very insecure) to give apache the ability to do things as root, but I need to be able to kill any user from a web page, does anyone have any good working scripts or point me to a place to find some more info? I can use this code (which I took from php.net) to make it work, but I assume that this will work only if I give apache root permission or run apache as root. <?php exec("kill -9 $pid"); ?>

Running Linux Command from PHP

依然范特西╮ 提交于 2020-01-11 11:18:10
问题 I have a bit of a unique situation. I'm trying to run a video encoding program from a PHP script called Diascope, which relies on the 'convert' command provided by ImageMagick. I have a bash script that executes a really simple conversion and then it runs the application called Diascope. This is the conversion code, and the following does work, it creates the new file convert image.jpg image.png Shows no errors, but then I run Diascope like this diascope -clean audio.txt And I can see that

error on using exec() to call python script

馋奶兔 提交于 2020-01-11 10:13:32
问题 I am trying to call a simple python script #!/usr/local/python25/bin/python print "hello world" from the following php script <?php echo exec("/usr/local/python25/bin/python myfile.py"); ?> But nothing was happened. Please tell me what is wrong here? (I also checked other thread but I could not solve my problem) Question Solved: I forgot to give the permission to access /usr/local/python25/bin/python. After I did this, the problem solved. Thank you so much for your help! 回答1: 1.The exec

PHP exec() use of memory

╄→гoц情女王★ 提交于 2020-01-11 05:43:38
问题 I can't seem to find a definitive answer for this one. When invoking a shell command using exec() from PHP, does the memory that shell command uses count towards the memory limit that the PHP script is given? I realise that if the command generates a lot of output, and that output is captured in the $ouput (second) parameter of exec() , then that returned data could blow the PHP memory limit. However, assuming all output is sent to a file, if the exec() command requires 128M of memory to run,

How can I run a program in the background (non blocking) with php?

无人久伴 提交于 2020-01-11 03:58:05
问题 I want to run a shell script in php, but this shell script takes a long time to execute (it has sleep in it), I don't want the web server to block when executing this script. I tried exec() and shell_exec() in php but the server stops until the shell script finishes! I thought of doing fork in the shell script itself but I don't know how to do that. I just want the php script to call this shell script and continue working, I'm not waiting any result from the script. I tried running the shell

How to use the name of the file with sed in a find expression

时光毁灭记忆、已成空白 提交于 2020-01-10 05:25:07
问题 Trying to answer Using Bash/Perl to modify files based on each file's name I ended in a point in which I don't know how to use find and sed all together. Let's say there is a certain structure of files in which we want to change a line, appending the name of the file. If it was a normal for loop we would do: for file in dir/* do sed -i "s/text/text plus $file/g" $file done But let's say we want to use find to change files from all subdirectories. In this case, I would use... find . -type f

How to use pipe within -exec in find

独自空忆成欢 提交于 2020-01-09 10:14:53
问题 Is there any way to use pipe within an -exec in find? I don't want grep to go through whole file, but only through first line of each file. find /path/to/dir -type f -print -exec grep yourstring {} \; I tried to put the pipelines there with "cat" and "head -1", but it didn't work very well. I tried to use parenthesis somehow, but I didn't manage to work out how exactly to put them there. I would be very thankful for your help. I know how to work it out other way, without using the find, but