shell_exec无法正常工作,可能是因为特殊字符

I have a command that i want to run from php

$shell = 'mysqldump -uuser -ppass --where="id>' . $larger .' and id<' . $smaller .'" view allasins | gzip -c | sshpass -p "pass2" ssh user2@host.com  \'cat>/home/user/domain.com/file.sql.gz\'';
$shell = escapeshellarg($shell); //this is not working, escapeshellcmd($shell) also not working
shell_exec($shell);

So, anyone know what is wrong with these codes? There is no error message, it simply does not work.

Thank you very much.

Try using

escapeshellcmd so :

$Command = escapeshellarg($shell);

The usage for

escapeshellarg()

is to escape individual strings, for it to work within your example:

$shell = 'mysqldump -uuser -ppass --where="id>' . escapeshellarg($larger) .' and id<' . escapeshellarg($smaller) .'" view allasins | gzip -c | sshpass -p "pass2" ssh user2@host.com  \'cat>/home/user/domain.com/file.sql.gz\'';