Le 2 juin 2010 à 22:41, Emmanuel Borlet a écrit :
> echo "<?PHP echo urlencode('4x^2-5xy+2y^2=4') ; ?>" | php
Merci.
Ça fonctionne … sauf si la chaîne initiale contient les caractères
apostrophe ou guillemets.
J'ai pourtant passé la dite chaîne à la moulinette :
quoted form of theString
set theString to "% !#$&()+,/:=^"
set theString to do shell script "echo " & quote & "<?PHP echo
urlencode(" & quoted form of theString & ") ; ?>" & quote & " | php"
set theString to "% !#$&()+,/:=^" & "'" & quote
set theString to do shell script "echo " & quote & "<?PHP echo
urlencode(" & quoted form of theString & ") ; ?>" & quote & " | php"
Ça me renvoie :
tell current application
do shell script "echo \"<?PHP echo urlencode('% !#$&()+,/:=^') ; ?>\"
| php"
"%25+%21%23%24%26%28%29%2B%2C%2F%3A%3D%5E"
do shell script "echo \"<?PHP echo urlencode('% !#$&()+,/:=^'\
\''\"') ; ?>\" | php"
"sh: -c: line 1: unexpected EOF while looking for matching `''
sh: -c: line 2: syntax error: unexpected end of file"
Ce n'est pas bien grave puisque le destinataire du script ne sait pas
s'il risque d'avoir les dits caractères dans les chaînes à traiter.
Yvan KOENIG (VALLAURIS, France) jeudi 3 juin 2010 13:57:22
_______________________________________________
archives :
http://listes.patpro.net/list/sshfr.fr.html
http://listes.patpro.net/mailman/listinfo/script_shell_fr