其他分享
首页 > 其他分享> > Total Commander SFTP路径斜杠和反斜杠的研究

Total Commander SFTP路径斜杠和反斜杠的研究

作者:互联网

在使用Total Commander通过SFTP插件访问Linux文件系统时,由于TC默认使用Windows的路径分隔符反斜杠“\”,而Linux文件系统的路径分隔符是斜杠“/”。这两个不同的符号表示习惯混在了一个场景里,就出现了迷惑模糊不清。在TC论坛上搜索了好久,多少有一点理解了。截取的原始信息目的为尽量准确还原作者英文原意,也作为以后的记忆备忘。自己的半瓶水英文水平,没准儿在哪句话上就理解错了,敬请指正,谢谢。


Total Commander作者Ghisler自己写的SFTP插件

来源: https://www.ghisler.com/plugins.htm

SFTP
2.50
2019/06/17
32+64 bitAllows to access remote servers via secure FTP (FTP via SSH). Requires SSH2. Now also supports SSH+SCP without SFTP!

NEW! On Windows Vista, 7 or newer, no extra DLLs are needed any more! It uses the sChannel secure library built into Windows.

New in 2.50: Support for ED25519 elliptic curve certificates
New in 2.40: Don't show error if login via keyboard interactive failed, but worked via password.
New in 2.30: Plugin no longer worked on Windows 10 1903 (Spring 2019).

For Windows XP, please get this separate version which only needs the OpenSSL DLLs:
sftpplugxp
Source available.


斜杠和反斜杠的详细说明

  • 斜杠“/”,英文叫做forward slash,Linux系统默认使用的路径分隔符就是这个,例如“/home/UserName/Documents”
  • 反斜杠“\”,英文叫做backslash,Windows系统默认使用的路径分隔符就是这个,例如“C:\Windows\System32\”

我也说晕了,我是这么记忆的,字母A,第一笔是斜杠,最后一笔是反斜杠。因为Unix/Linux出现的早,所以是第一笔(斜杠);因为Windows出现的晚,所以是最后一笔(反斜杠)


While the forward slash may work in many places, TC expects the backslash.

Use of alternate path separator

Post by *koahnig » 2015-10-13, 12:22 UTC

Hi there,
I am not sure if I should file a bug report. Also I am struggling in getting a reasonable list of bug reports for checking for this problem.

Anyway, I am using the button bar and I have created a new icon for simply changing the current drive and folder.

The command is: cd d:/OwnCloud.
This command is working in most cases fine. I can change to subfolders and do the typically navigational stuff.

Some weird behaviour starts when moving one folder back. The window will show directly the root folder. Also an error message appears when using the sync folder feature.

The origin is the use of the forward slash as separator.
It will show d:\/OwnCloud/** as the new folder but probably should have been converted to d:\OwnCloud**

This is with TotalCommander 8.52a 64 bit on Windows 10.

The command has been used already under Win 7 64 bit, but I am not sure if there has been the same problem.

I have changed to standard folder separator for windows **** and all is working fine for me.

Top

Power Member Power Member

Posts: 3616

Joined: 2003-02-06, 17:36 UTC

Location: Germany

Post by *Horst.Epp » 2015-10-13, 12:40 UTC

This is not a TC bug !
The /OwnCloud is of course interpreted as command line switch which makes no sense in this context.

Top

Power Member Power Member

Posts: 2770

Joined: 2007-09-13, 22:20 UTC

Location: Europa

Post by *Stefan2 » 2015-10-13, 12:45 UTC

Hi,

and what is the actual problem now?

Just use the standard folder separator for windows \ and all is working fine :wink:

On my test I nowhere see such "d:\/OwnCloud/\" behavior. ( Tested with CD e:/temp)
Locks like some escaping...
WHERE did you saw that string?

.

Inofficial FAQs || WIKI (Deu/Eng) || TC Home (What's new? // FAQ // Download // Order // Addons // Tools // Plugins)

Top

Junior Member Junior Member

Posts: 6

Joined: 2015-02-18, 11:32 UTC

Post by *koahnig » 2015-10-13, 19:01 UTC

The command "cd d:/OwnCloud" is used within button bar icon.

The problem is with 8.52a and 8.52.
I have just tried on my laptop with TC 8.52. It does change to the folder as well, but the same problems.
Both machines are running Win10 64 bit. Both TC versions are also 64 bit.

The string appears above the pane window and below the tabs where typically the current complete folder path is shown. For 8.52 the end of the path does not have the combination of forward and backward slashes.

Thanks for suggestion, but I had solved it already as written in initial post. I merely thought to report it. Personally I do consider it as a minor bug.

Top

Power Member Power Member

Posts: 8467

Joined: 2008-08-03, 12:51 UTC

Location: Russian Federation

Post by *MVV » 2015-10-13, 19:31 UTC

Standard folder name separator for Windows is backslash so many programs may not work correctly if you use forward slashes instead.

TCFS2 + TCFS2Tools: Full-screen mode for TC etc (forum)
TOTALCMD.NET: AskParam, CopyTree, NTLinks, Sudo, VirtualPanel…

Top

Site Admin Site Admin

Posts: 39354

Joined: 2003-02-04, 09:46 UTC

Location: Switzerland

Contact: Contact ghisler(Author)

Post by *ghisler(Author) » 2015-10-15, 14:04 UTC

Yes, please use backslashes in TC for local paths. While the forward slash may work in many places, TC expects the backslash.

Author of Total Commander
http://www.ghisler.com

Top

Post Reply

6 posts • Page 1 of 1

来源: https://www.ghisler.ch/board/viewtopic.php?f=3&t=42876&hilit=forward+slash


The forward slash is interpreted like a backslash by Windows, but ignored by TC. Please don't use the forward slash in file names.


Post
by *ghisler(Author) » 2007-09-09, 08:56 UTC

The forward slash is interpreted like a backslash by Windows, but ignored by TC. Please don't use the forward slash in file names.

Author of Total Commander
http://www.ghisler.com

来源: https://www.ghisler.ch/board/viewtopic.php?f=20&t=16935


the SFTP plugin accepts both paths with backslashes and forward slashes

Command line in SFTP plugin

Post by *charly_35 » 2013-09-19, 13:48 UTC

LO,
I was using the FTP that is part of TC and I added the plugin for SFTP.
I notice a difference between the 2 :
when connected the command from the directory menu (cd /my_directory/data) is well passed when in FTP but not when in SFTP.
Nothing in log window. and the new position is on my computer to C.\
Is there a reason for ?
When I wrote it in the TC cmd line it's OK in FTP and SFTP
Regards
Charles.

Cdlt Charles.

Top

Site Admin Site Admin

Posts: 39354

Joined: 2003-02-04, 09:46 UTC

Location: Switzerland

Contact: Contact ghisler(Author)

Post by *ghisler(Author) » 2013-09-19, 13:53 UTC

I have just tried it, the SFTP plugin accepts both paths with backslashes and forward slashes. Just check the path in the title, you may have to put
/home/username
in front of the path.

Author of Total Commander
http://www.ghisler.com

Top

Junior Member Junior Member

Posts: 20

Joined: 2010-03-26, 17:14 UTC

Location: France Rennes 35

Post by *charly_35 » 2013-09-19, 14:50 UTC

[quote="ghisler(Author)"]I have just tried it, the SFTP plugin accepts both paths with backslashes and forward slashes. Just check the path in the title, you may have to put
/home/username
in front of the path.[/quote]
It's not a slash or backslash pb.
it's just the command "cd /home/username" that I have added in the directory menu that work OK in FTP window and not in the SFTP one.
The connexion is already done, it is just to swtch to the "/home/username" directory from anywhere in my FTP or SFTP connexion.
Regards Charles.

Cdlt Charles.

来源: https://www.ghisler.ch/board/viewtopic.php?f=6&t=19994&p=270879&hilit=forward+slash#p270879


Post
by *ghisler(Author) » 2013-09-22, 13:08 UTC

2charly_35
Ah, sorry, I thought that you use the bottom command line. For a button, you need to drag the path to the plugin to the button bar. This will add the full path including the plugin name in the form:
cd \\pluginname\servername\home\user\subdir

来源: https://www.ghisler.ch/board/viewtopic.php?f=6&t=19994&hilit=forward+slash&start=870


把SFTP的定制化路径加入工具栏,“cd \\\Secure FTP\yourconnection\home\yourname”

2franck8244

Could you add a "cd .." entry on the file list to go up on the server side and not on the plugin side ?

I'm sorry but it's not possible with the current plugin interface to go above the root.

Instead, create a new connection for the root, then add a button to the TC button bar to go directly to the home dir:
cd \\\Secure FTP\yourconnection\home\yourname
来源: https://www.ghisler.ch/board/viewtopic.php?f=6&t=19994&hilit=forward+slash&start=15


把SFTP的定制化路径加入工具栏,“cd \\\pluginname\subfolder”


Post
by *ghisler(Author) » 2009-12-28, 16:09 UTC

No, file system plugins work similar to UNC paths (e.g. \server\share) in TC: They don't have drive letters, but you can add them to the button bar in the form:
cd \\\pluginname\subfolder

Just drag a plugin folder to the button bar to add a button.

Author of Total Commander
http://www.ghisler.com

来源: https://www.ghisler.ch/board/viewtopic.php?f=6&t=19994&p=193056&hilit=%5C%5Cpluginname%5C#p193056


A forward slash means all file system plugins, a backslash means all UNC paths


Post
by *MaXyM » 2013-05-26, 10:26 UTC

While using sftp plugin (by Christian Ghisler) and close TCMD leaving connection in one or more panes, it TCMD tries to reconnect while starting it next time.

I believe such behaviour may be useful in some cases. But consider using putty agent. You have to remember all the time to run Pageant before running TCMD, otherwise you have to way a few seconds (connection attempt) and click out connection error modal requester.
All those things takes time and making it annoying after some retries.

I would ask is there is some possibility to disable automatic connect the SFTP server just after TCMD start. Or maybe, to run Pageant automatically if not running yet.

Please consider feature-wise solution. I believe, similar problems may be caused while using microsoft network. In short, remember and open remote storages automatically after start must not be optimal solution.

with regards

Top

Power Member Power Member

Posts: 3616

Joined: 2003-02-06, 17:36 UTC

Location: Germany

Post by *Horst.Epp » 2013-05-26, 12:48 UTC

MaXyM wrote:While using sftp plugin (by Christian Ghisler) and close TCMD leaving connection in one or more panes, it TCMD tries to reconnect while starting it next time.

I believe such behaviour may be useful in some cases. But consider using putty agent. You have to remember all the time to run Pageant before running TCMD, otherwise you have to way a few seconds (connection attempt) and click out connection error modal requester.
All those things takes time and making it annoying after some retries.

I would ask is there is some possibility to disable automatic connect the SFTP server just after TCMD start. Or maybe, to run Pageant automatically if not running yet.

Please consider feature-wise solution. I believe, similar problems may be caused while using microsoft network. In short, remember and open remote storages automatically after start must not be optimal solution.

with regards

And why don't you disable the option to remember last used Directories ?
Configuration / Operation / Save on Exit

Top

Junior Member Junior Member

Posts: 7

Joined: 2013-05-26, 10:12 UTC

Post by *MaXyM » 2013-05-26, 15:12 UTC

I could, but this option is useful for local disks/directories.
It's problematic only for remote directories.

Top

Power Member Power Member

Posts: 3616

Joined: 2003-02-06, 17:36 UTC

Location: Germany

Post by *Horst.Epp » 2013-05-26, 15:26 UTC

MaXyM wrote:I could, but this option is useful for local disks/directories.
It's problematic only for remote directories.

I found it much better to always start with a certain set of dirs
and not with anything left from last usage.
Also I never stop TC between reboots of my PC.

Top

Site Admin Site Admin

Posts: 39354

Joined: 2003-02-04, 09:46 UTC

Location: Switzerland

Contact: Contact ghisler(Author)

Post by *ghisler(Author) » 2013-05-27, 10:11 UTC

Please go to "Configuration - Options - Refresh". Then put the following in the box "Do not remember these drives on exit":
/

A forward slash means all file system plugins, a backslash means all UNC paths, and letters stand for the drives with these letters.

Author of Total Commander
http://www.ghisler.com

来源: https://www.ghisler.ch/board/viewtopic.php?f=6&t=28609&start=15


convert path to forwardslash with TCMC


Post
by *karlchen » 2011-09-27, 14:37 UTC

Hello, dragonetti.

It get's copied to:
\\Secure FTP\vps - root\root\scripttest\filename.sh
The bold part isn't needed, is it possible to exlude te first 2 parts (bold parts)?

There is no way of achieving your goal by using Total Commander internal commands only.
Yet, there are different ways of achieving your goal by using scripting tools like AHK.
Please, have a look at this thread where one of the goals is exactly what you want to achieve, stripping parts of the full pathname. Yet, beware, the target platform in that thread is not so much Windows, but Total Commander on Linux with Wine. In order to use the given examples on Windows you may have to modify the quoted commands a bit.
Thread copy path to clipboard - wine

Depending on how flexible your command needs to be the following utilities will be helpful:
+ Lefteous's Lst2Clip
+ TCMC (send mutliple commands to T.C.
+ UnxUtils

Here is the command which can be found in the linked thread as well and which I use in order to strip the unneeded prefix from the SFTP pathnames:

  1. %COMMANDER_PATH%..\TC_Addons\TCMC.exe 50 CMcm_CopyFullNamesToClip EMem_ConvertSSHToSlash

This is the button that uses TCMC in order to tell T.C. to copy the full pathname to the clippboard and that next launches the command to transform the clipboard content

  1. [em_ConvertSSHToSlash]
    button=WCMICONS.DLL,59
    cmd=cmd.exe
    param=/c pclip| sed -e "s#\#/#g" -e "s#///Secure FTP/.{8}[^/]*/#/#g" | gclip
    menu=sshpath
    path=%COMMANDER_PATH%..\TC_Addons

This user defined command uses the UnxUtils to strip the unneeded prefix of the SFTP full pathname and push the resulting pathname back into the clipboard.

  1. Note: the pathname will be in Linux notation, i.e. it will use forward slash instead of backslash in order to separate path names.

HTH,
Karl

来源: https://www.ghisler.ch/board/viewtopic.php?f=6&t=19994&start=675


How to copy file path with forward slash? with Add-on

How to copy file path with forward slash?

Moderators: sheep, Hacker, Stefan2, white

Post Reply

SearchAdvanced search

2 posts • Page 1 of 1

New Member New Member

Posts: 1

Joined: 2019-05-30, 18:41 UTC

How to copy file path with forward slash?

Post by *Laish » 2019-05-30, 18:49 UTC

Hi,

I'm currently using an Hotkey to run the command cm_CopyFullNamesToClip.
In the clipboard the path is set with backslash (i.e c:\dev\file.txt).

I would like to have the path with forward slash (i.e. c:/dev/file.txt), Is there any settings that influence that?

I know i can write a script and put it in the shortcuts bar (something like this https://superuser.com/a/977847) but i want to use the keyboard shortcut to run it.

Does anybody have any idea how to achieve that?

Thank you!

Top

Power Member Power Member

Posts: 2771

Joined: 2007-09-13, 22:20 UTC

Location: Europa

Re: How to copy file path with forward slash?

Post by *Stefan2 » 2019-05-30, 18:59 UTC

Hi and welcome Laish.

Instead of into the shortcuts bar (buttonbar) you can write with that commands and parameters a "user defined command" (usercmd.ini),
which you can assign a keyboard shortcut to. (Configuration > Options > Misc.)

To aid you whit your actual task you can try to use an Add-on instead of an own script:
https://totalcmd.net/plugring/list2clip.html

viewtopic.php?t=1853

Or just use PowerShell:
https://ghisler.ch/board/viewtopic.php?t=48019

The forum is full with tips and tricks, just search for that keywords....

Inofficial FAQs || WIKI (Deu/Eng) || TC Home (What's new? // FAQ // Download // Order // Addons // Tools // Plugins)

来源: https://www.ghisler.ch/board/viewtopic.php?f=3&t=52797


Copy path name with forward slash, with List2Clipboard, or Auto Hot Key

Copy path name with forward slash

Post by *yxz11 » 2011-01-23, 13:20 UTC

All,

Is there a function to copy path name with forward slash? I need the functionality like cm_CopyFullNamesToClip, instead of '\' I would like to get '/'. Here is an example:

I have file "c:\temp\test.txt", after cm_CopyFullNamesToClip, I got
"c:\temp\test.txt". Is there a way I can get "c:/temp/test.txt".

I need this for R.

Thanks,

Top

Power Member Power Member

Posts: 1936

Joined: 2003-11-13, 13:40 UTC

Location: Schweiz

Re: Copy path name with forward slash

Post by *Peter » 2011-01-25, 09:11 UTC

yxz11 wrote:...I need this for R....

What is R?

Take a look at List2Clipboard - there are many user-settings
http://www.totalcmd.net/plugring/list2clip.html

Peter

TC 9.22a / #266191
Win 7 x64 / Win 10 x64

Top

Power Member Power Member

Posts: 794

Joined: 2005-09-14, 22:19 UTC

Location: Russia

Contact: Contact Vochomurka

Post by *Vochomurka » 2011-01-25, 09:18 UTC

http://ppro.totalcmd.net/Scripts/ClipFileList.htm
http://ppro.totalcmd.net/Scripts/ClipListDialog.htm

Single user license #329241
PowerPro scripts for Total Commander

Top

Power Member Power Member

Posts: 2148

Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom » 2011-01-25, 15:18 UTC

If you use AHK, this would do it

CODE: SELECT ALL

; TC_backslash2forward.ahk
;
PostMessage, 0x433, 2018, 0,, A
ClipWait
StringReplace, Clipboard, Clipboard, , /, A

Example Button:
Command: %ProgramFiles%\AutoHotkey\AutoHotkey.exe "%ProgramFiles%\AutoHotkey\Scripts\TC_backslash2forward.ahk"

Top

New Member New Member

Posts: 1

Joined: 2013-05-20, 06:49 UTC

autohotkey

Post by *janislaw » 2013-05-20, 07:01 UTC

I am using custom Total commander keyboard shortcuts ALT+INSERT and ALT+SHIFT+INSERT for cm_CopyNamesToClip and cm_CopyFullNamesToClip (you can set them in Options on Misc tab).
My solution based on previous AHK script is resident and catches ALT+SHIFT+INSERT before forwarding it to Total commander and afterwards it modifies the clipboard.
Here is content of autohotkey script (you can save it to windows Startup folder to keep it running after restart):
#IfWinActive, ahk_class TTOTAL_CMD
!+Insert::
Send !+{Insert}
ClipWait
StringReplace, Clipboard, Clipboard, , /, A

来源: https://www.ghisler.ch/board/viewtopic.php?f=3&t=28439


现状下该如何在Linux场景下使用路径?--(输入)路径地址到达目标文件夹

\\Secure FTP\yourconnection\home\yourname是可以正常工作的,如下图一
\\Secure FTP\yourconnection/home/yourname也是可以正常工作的,如下图二


现状下该如何在Linux场景下使用路径?--(输出)文件路径地址分享给别人或者其他程序(比如Linux 终端)
根据上文中的几个copy path as Linux (forwardslash)的方案,看起来是完全可行的。目前还没有这个需求,所以就不亲自验证了。



来自为知笔记(Wiz)





标签:UTC,slash,Commander,ghisler,斜杠,forward,path,Post,SFTP
来源: https://www.cnblogs.com/yuguangtai/p/12577240.html