shell-exec

Call a program via shell_exec with utf-8 text input

馋奶兔 提交于 2019-12-30 12:16:11
问题 Perquisites: hunspell and php5 . Test code from bash: user@host ~/ $ echo 'sagadījās' | hunspell -d lv_LV,en_US Hunspell 1.2.14 + sagadīties - works properly. Test code (test.php): $encoding = "lv_LV.utf-8"; setlocale(LC_CTYPE, $encoding); // test putenv('LANG='.$encoding); // and another test $raw_response = shell_exec("LANG=$encoding; echo 'sagadījās' | hunspell -d lv_LV,en_US"); echo $raw_response; returns Hunspell 1.2.14 & sagad 5 0: tagad, sagad?ties, sagaudo, sagand?, sagar?o * *

Call a program via shell_exec with utf-8 text input

Deadly 提交于 2019-12-30 12:16:05
问题 Perquisites: hunspell and php5 . Test code from bash: user@host ~/ $ echo 'sagadījās' | hunspell -d lv_LV,en_US Hunspell 1.2.14 + sagadīties - works properly. Test code (test.php): $encoding = "lv_LV.utf-8"; setlocale(LC_CTYPE, $encoding); // test putenv('LANG='.$encoding); // and another test $raw_response = shell_exec("LANG=$encoding; echo 'sagadījās' | hunspell -d lv_LV,en_US"); echo $raw_response; returns Hunspell 1.2.14 & sagad 5 0: tagad, sagad?ties, sagaudo, sagand?, sagar?o * *

shell_exec() and exec() not working in PHP

安稳与你 提交于 2019-12-30 11:09:36
问题 Like many others I have problem with shell_exec() function in PHP. I have safe mode disabled and disabled_functions deleted from php.ini. If I run php script from terminal (php print.php) it's working perfectly but if I run it from web browser nothing happens. Here is the scipt: <?php $output = shell_exec('lp print.php'); echo "<pre>$output</pre>"; ?> Please help me. I'm running PHP 5.3.10 on Apache2. My OS is Ubuntu Server 12.4. Here is the phpinfo page: http://testni-server.info/info.php

CreateProcess and ShellExecute differences

*爱你&永不变心* 提交于 2019-12-30 06:10:07
问题 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? 回答1: 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

Save shell output to variable

怎甘沉沦 提交于 2019-12-25 07:18:46
问题 I am trying to compress a jpg with mogrify (GraphicsMagicks) and i need to store the result in a variable. $compressed_jpg_content = shell_exec("gm mogrify -quality 85 - < ".escapeshellarg($image_path)." $filename.jpg"); if (!$compressed_jpg_content) { throw new Exception("Conversion to compressed JPG failed"); } However its not working and i get Conversion to compressed JPG failed and i think there is a problem with my command Edit Thanks to Allen Butler In this case $image_path is actually

Open gnome-terminal from php script

折月煮酒 提交于 2019-12-25 05:50:05
问题 I want to try to open gnome-terminal from php script: shell_exec('bash /data/manager/application/.shell/system.sh'); This script use a function to check terminal: SCRIPTCURRENT=`readlink -m $0` SCRIPTCURRENTPATH=$(dirname "$SCRIPTCURRENT") runintoterminal () { if ! [ -t 1 ]; then gnome-terminal -e "bash $1" exit 0 fi } runintoterminal $SCRIPTCURRENT I've tried: shell_exec('gnome-terminal'); But it's doesn't work... (I know it's possible...) But how to ? I use nginx and php-fpm. With my own

placing PHP variable inside of shell_exec( ) to run lsp command

泪湿孤枕 提交于 2019-12-25 03:34:28
问题 When the url .../print.php loads, I want the name of the latest file uploaded to the target directory to be printed and for that same file to simultaneously be sent to the printer connected to the server. With this code here, I am able to do everything that I want ONLY when the shell_exec(lsp /file/path) refers directly to a file. I have a function set up that determines the latest file uploaded and also the filepath, but I want to do something like shell_exec(lsp $filepath). <?php $path = "

How can I access the data I got back from shell_exec?

淺唱寂寞╮ 提交于 2019-12-24 16:01:03
问题 I have a php script, then I run it line by line. I run this line: $ip = trim(shell_exec("dig +short myip.opendns.com @resolver1.opendns.com")); I got : 50.198.81.174 Then I run the next line: $php_info = trim(shell_exec("curl ipinfo.io/".$ip)); I got """ {\n "ip": "50.198.81.174",\n "hostname": "50-198-81-174-static.hfc.comcastbusiness.net",\n "city": "Braintree",\n "region": "Massachusetts",\n "country": "US",\n "loc": "42.2038,-71.0022",\n "org": "AS7922 Comcast Cable Communications, Inc.",

ERROR: Repository not found whilst running git pull via shell_exec on php script

梦想与她 提交于 2019-12-24 09:03:29
问题 I have set up ssh keys properly and added them to my github account . Whenever I ssh into the server and run git pull , everything runs normally and it pulls changes from the repository . However I have a deploy script that runs git pull via shell_exec() but it returns this error; origin git@github.com:sayopaul/autodeploy-tutorial.git (fetch) origin git@github.com:sayopaul/autodeploy-tutorial.git (push) ERROR: Repository not found. fatal: Could not read from remote repository. Please make

php shell_exec permission denied

℡╲_俬逩灬. 提交于 2019-12-23 15:51:03
问题 shell_exec("touch /Users/Nerses/Downloads/ads.txt 2>&1") I have a problem with the PHP exec(shel_exec) function. It says that I do not have permissions to execute the command. How can I open these permissions? 回答1: Your PHP code is trying to access /Users/Nerses/Downloads/ads.txt , as you can see, that folder is owned by the user called "Nerses". He is the only one (and root) who can access it (unless you change the permissions to that folder). Normally, the user that executes shell_exec is