سؤال

OK so I have this line,

$ssh->exec('cd E:\\Titan\ Torque\\Jobs');

Now how to I use this with the double slashes? I mean I need 2 slashes to be sent not one the command:

cd E:\\Titan\ Torque\\Jobs

Is what I need to be executed.

P.S. The ssh server is running on windows, this command runs fine in putty but PHP is stripping it down to:

cd E:\Titan\ Torque\Jobs

Any help would be appreciated.

هل كانت مفيدة؟

المحلول

I think if you escape the backslashes with backslashes, they should work.

$ssh->exec('cd E:\\\\Titan\\ Torque\\\\Jobs');

In a test:

echo 'E\\:a thing with\slashes\\';
echo "\n";
echo 'E\\\\:a thing with\\\\slashes\\';

gives

E\:a thing with\slashes\ 
E\\:a thing with\\slashes\

In case you're curious, the reason a single backslash works at all, is because \ isn't a special escape sequence so it's put into the resultant string literally.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top