note 78279 added to function.shell-exec

From: Date: Fri, 05 Oct 2007 09:01:41 +0000
Subject: note 78279 added to function.shell-exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-131111@lists.php.net to get a copy of this message
I had trouble with accented caracters and shell_exec. ex : Executing this command from shell : /usr/bin/smbclient '//BREZEME/peyremor' -c 'dir' -U 'peyremor%*********' -d 0 -W 'ADMINISTRATIF' -O 'TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192' -b 1200 -N 2>&1 gave me that : Vidéos D 0 Tue Jun 12 14:41:21 2007 Desktop DH 0 Mon Jun 18 17:41:36 2007 Using php like that : shell_exec("/usr/bin/smbclient '//BREZEME/peyremor' -c 'dir' -U 'peyremor%*******' -d 0 -W 'ADMINISTRATIF' -O 'TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192' -b 1200 -N 2>&1") gave me that : Vid Desktop DH 0 Mon Jun 18 17:41:36 2007 The two lines were concatenated from the place where the accent was. I found the solution : php execute by default the command with LOCALE=C. I just added the following lines before shell_exec and the problem was solved : $locale = 'fr_FR.UTF-8'; setlocale(LC_ALL, $locale); putenv('LC_ALL='.$locale); Just adapt it to your language locale. ---- Server IP: 195.221.21.36 Probable Submitter: 193.51.172.10 ---- Manual Page -- http://www.php.net/manual/en/function.shell-exec.php Edit -- https://master.php.net/note/edit/78279 Del: integrated -- https://master.php.net/note/delete/78279/integrated Del: useless -- https://master.php.net/note/delete/78279/useless Del: bad code -- https://master.php.net/note/delete/78279/bad+code Del: spam -- https://master.php.net/note/delete/78279/spam Del: non-english -- https://master.php.net/note/delete/78279/non-english Del: in docs -- https://master.php.net/note/delete/78279/in+docs Del: other reasons-- https://master.php.net/note/delete/78279 Reject -- https://master.php.net/note/reject/78279 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131111) next »