| Handbook Page ID | 25 |
"SSH2 Remote Copy" in Token2Shell uses the existing SSH connection, i.e., it opens an additional independent channel over the existing connection and communicates with server about file and folder information.
During this process you may wish to automatically set the current working directory path as the source or destination path for file transfer. You can set the path in two ways:

If you set the window title with path information as the last item, Token2Shell should be able to automatically extract the path information from that title.
|
Please note that '^[' and '^G' in these examples are control characters, <ESC> and <BEL> respectively. Control characters can be entered in tcsh command prompt by pressing <CTRL> + V and then the actual control character. For example, if you wish to enter <ESC> control character, press <CTRL> + V and then hit <ESC> key.
alias cwdcmd 'echo -n "^[]5001;${cwd}^G"'
#!/bin/sh
echo -n '^[]5001;'
echo -n "$PWD"
echo -n '^G'
echo -n '^[]5003;'
while [ $# -ge 1 ]; do
echo -n '"'"$1"'" '
shift
done
echo -n '^G'
Assuming that you have created an executable file with the above script and named it "t2sf",
you can invoke Token2Shell download by typing:
%t2sf file1.zip file2.zip
This command will invoke Token2Shell download and add "file1.zip" and "file2.zip" to the download file list edit box. You then just need to press the "Download" button to start the file transfer.

bash has an environment variable called 'PROMPT_COMMAND' and this variable is executed just before bash displays a prompt. Hence, setting the variable as below should allow Token2Shell to properly adjust its copy of the path info. (For configuring the variable, you should edit ".bash_profile" under your $HOME directory.)
PROMPT_COMMAND='echo -ne "\033]5001;"; if [ ${PWD:0:${#HOME}} == ${HOME} ] && ([ ${#PWD} == ${#HOME} ] || [ ${PWD:(${#HOME}):1} == "/" ]); then echo -ne ".${PWD:${#HOME}}"; else echo -ne "${PWD}"; fi; echo -ne "\007";'; export PROMPT_COMMAND
Please note that the above example removes the beginning portion of the path if it matches your $HOME directory path and replaces it with ".". For example, if your $HOME path is "/home/user1" and the current path is "/home/user1/pub", the script returns "./pub". This behavior should be preferable if your SFTP configuration doesn't allow accessing outside of your $HOME directory or using full absolute path.
Recent comments
1 year 6 hours ago
1 year 1 week ago
1 year 1 week ago
1 year 2 weeks ago
1 year 2 weeks ago
1 year 2 weeks ago
1 year 2 weeks ago
1 year 4 weeks ago
1 year 6 weeks ago
1 year 17 weeks ago