hi *,
i have a problems in string. i want to exec a shell command from php. when i want to change password of user the shell command is
if password is x'>
./pwdsync.sh 'local001' 'x'\''>'
if password is '
./pwdsync.sh 'local001' \'
and code in php
$txtpwd = str_replace("'","'\'\\\'\''",$txtpwd);
exec('/opt/ua/sh/pwdsync.sh \'' . $mnid . '\' \'' . $txtpwd . '\'');
but i can't do it successful. if i use
exec('/opt/ua/sh/pwdsync.sh \'' . $mnid . '\' \'' . '\'\\\'\'' . '\'');
the password change to ' successfully. and when i echo txtpwd, it's not match with the string i assigned.
plz, help me.
PHP string variable and string
Moderator: General Moderators
thank you, i've done it.
thank you *, i've done it. and now i having coffe and tabaco with a smiling face.
i use this command to make it works.
$txtpwd = str_replace(chr(39),chr(39).'\\'.chr(39).chr(39),$txtpwd);
exec('/opt/ua/sh/pwdsync.sh \'' . $mnid . '\' \'' . $txtpwd . '\'');

i use this command to make it works.
$txtpwd = str_replace(chr(39),chr(39).'\\'.chr(39).chr(39),$txtpwd);
exec('/opt/ua/sh/pwdsync.sh \'' . $mnid . '\' \'' . $txtpwd . '\'');
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
escapeshellcmd() may be a better choice.