I am attempting to run a Microsoft osql query via a Cygwin ssh call on Windows
via PHP's system function.
This command works fine:
system("ssh -l myuser myserver \"osql -S SQLServer -d SQLDB -U sqluser -P
sqlpassword -Q \\"select * from MY_TABLE where MY_TABLE = 'ABC'\\"\"", $rc);
If I include a greater than (>) or less than (<) operator in my SQL, the
operator is treated as a shell redirection.
This command does not work:
system("ssh -l myuser myserver \"osql -S SQLServer -d SQLDB -U sqluser -P
sqlpassword -Q \\"select * from MY_TABLE where MY_TABLE > 'ABC'\\"\"", $rc);
I get an error from Windows:
"The filename, directory name or volume label syntax is incorrect."
I tried escaping the >. I've tried addslashes(), escapeshellarg(), escapeshellcmd(). No luck.
I can get the command to work directly from the Cygwin shell, so I know the
syntax is valid. It's just a matter of constructing my string with the proper
escape sequence.
How can I generate my command so that the comparison operator is not
interpreted as a shell redirection?