shell-exec

CreateProcess and ShellExecute differences

依然范特西╮ 提交于 2019-11-30 18:45:57
What are the main differences between the two? I'm willing to run only another EXE from my (C++) application. Are there any differences when inheriting environments, security features etc? The main difference between CreateProcess and ShellExecute is the following: CreateProcess is more oriented on low level and ShellExec on the high user lever which see the user in explorer. For example using of CreateProcess one can use command line which length is more as MAX_PATH . It has 32,768 characters restriction. You can also use CreateProcess to start program (if you have enough permissions) on

PHP detect if shell_exec() command failed

会有一股神秘感。 提交于 2019-11-30 17:18:43
问题 I'm running the ffmpeg command within PHP's shell_exec() to convert several videos in a list. Is there anyway to detect if an error happened while the video was being converted (or atleast verify it fully completed the conversion)? I don't want to stop converting other videos if an error happens, just the ability to record the error. <?php shell_exec('ffmpeg -i downloads/flv/file1.flv -vcodec libvpx -acodec libvorbis downloads/webm/file1.webm'); if(error) { //run a command here to report the

PHP shell_exec wait for script to finish? [duplicate]

夙愿已清 提交于 2019-11-30 04:18:57
问题 This question already has answers here : php exec command (or similar) to not wait for result (6 answers) Closed 4 years ago . I have a PHP script that queries a database for a list of jobs to be done and fires off other PHP scripts based on what it finds in the database (basically a process queue). Some of the scripts that the queue runner script executes may take 30 seconds or so to finish running (generating PDFs, resizing images, etc). The problem is that shell_exec() in the queue runner

php shell_exec with realtime updating

╄→尐↘猪︶ㄣ 提交于 2019-11-29 04:34:25
I have this shell program that I want to execute by php. The problem is that it can potentially take a long time, and as of that I need it to have real-time updating to the user's browser. I read that I may need to use popen() to do that, but I am sort of (ok, I really am :P) a PHP noob and can't figure out how I may be able to do it. Would appreciate any help! if( ($fp = popen("your command", "r")) ) { while( !feof($fp) ){ echo fread($fp, 1024); flush(); // you have to flush buffer } fclose($fp); } there are two possible behaviors: Non Block, where you need to do something else between flushs

Running shell script from java code and pass arguments

偶尔善良 提交于 2019-11-28 14:31:07
I am executing a shell script from Java program. I have implemented it using Runtime class. Below is the code I implemented final StringBuilder sb = new StringBuilder("test.sh"); sb.append("/path to/my/text file"); final Process p = Runtime.getRuntime().exec(sb.toString()); Here sb is string buffer object where I append my parameters and use it in exec method. But the problem is the parameter I pass "/path to/my/text file" is considered as 4 parameters /path to /my/text file But if run in shell as test.sh "/path to/my/text file" which is taken as single parameter. How can I achieve the same

How to run shell script with live feedback from PHP?

白昼怎懂夜的黑 提交于 2019-11-28 14:00:45
How would I execute a shell script from PHP while giving constant/live feedback to the browser? I understand from the system function documentation: The system() call also tries to automatically flush the web server's output buffer after each line of output if PHP is running as a server module. I'm not clear on what they mean by running it as a 'server module'. Example PHP code: <?php system('/var/lib/script_test.sh'); Example shell code: #!/bin/bash echo "Start..." for i in {1..10} do echo "$i..." sleep 1 done echo "Done." What this does: It will wait about 10 seconds and then flush to the

Using PHP to execute cmd commands

血红的双手。 提交于 2019-11-28 09:24:48
How do I properly execute commands in the command line using php? For example I'm using the command below in the command line to convert a docx file into a pdf file: pdfcreator.exe /PF"D:\Documents\sample.docx Now using PHP code I want to be able to execute the same command but nothing seems to be happening: <?php shell_exec('pdfcreator.exe /PF"D:\Documents\sample.docx"'); ?> Is this possible in PHP?If yes, how do I do it? system("c:\\path\\to\\pdfcreator.exe /PF\"D:\\Documents\\sample.docx""); try this. Don't forget to escape your command with escapeshellcmd() . This will prevent you from

executing a Powershell script from php

牧云@^-^@ 提交于 2019-11-28 08:33:49
I'm trying to execute a powershell script from PHP, but it does not seem to work. The script 'newEvent.ps1' creates an event on the Exchange server. $psPath = "powershell.exe"; $psDIR = "C:\\wamp\\www\\ant\\assets\\ps\\"; $psScript = "newEvent.ps1"; $runScript = $psDIR. $psScript; $runCMD = $psPath." ".$runScript." 2>&1"; echo "\$psPath $psPath <br>"; echo "\$psDIR $psDIR <br>"; echo "\$psScript $psScript <br>"; echo "\$runScript $runScript <br>"; echo "\$runCMD $runCMD <br>"; exec( $runCMD,$out,$ret); echo "<pre>"; print_r($out); print_r($ret); echo "</pre>"; It outputs: $psPath powershell

Running python script in Laravel

人走茶凉 提交于 2019-11-27 20:15:56
So, I am trying to run a python script in my Laravel 5.3. This function is inside my Controller. This simply passes data to my python script public function imageSearch(Request $request) { $queryImage = 'c:\\\xampp\\\htdocs\\\identificare_api\\\public\\\gallery\\\herbs\\\query.png'; //queryImage $trainImage = 'c:\\\xampp\\\htdocs\\\identificare_api\\\public\\\gallery\\\herbs\\\2nd.png'; //trainImage $trainImage1 = 'c:\\\xampp\\\htdocs\\\identificare_api\\\public\\\gallery\\\herbs\\\3rd.png'; $trainImage2 = 'c:\\\xampp\\\htdocs\\\identificare_api\\\public\\\gallery\\\herbs\\\4th.jpg';

Querying an audio/video file for information

我怕爱的太早我们不能终老 提交于 2019-11-27 18:57:03
问题 I want a PHP function which receives the path to a file and returns an array of information about it. The PHP file can call FFmpeg. Returned data should be something like Array( [mime] => video/ogg [container] => Ogg [video] => Theora [audio] => Vorbis [duration] => 20.3 // in seconds ) Array( [mime] => audio/ogg [container] => Ogg [video] => [audio] => FLAC [duration] => 3 ) Array( [mime] => image/gif [container] => GIF [video] => Animated GIF [audio] => [duration] => 2 ) Array( [mime] =>