drba1172 2014-03-10 15:27
浏览 19
已采纳

phpseclib,使用双斜线

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.

  • 写回答

1条回答 默认 最新

  • dongxun7962 2014-03-10 15:32
    关注

    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 "
    ";
    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料