5 echo -en "\033]777;inbandfiletransfer;$1\007"
18 -*) echo "Unknown option: $1" >&2
30 if [ -n "$SSH_CLIENT" ]
32 terminalSystem
=${SSH_CLIENT%% *}
35 echo "Usage: $0 [-d <path> | -u [path]]
36 -d Download from system running shell to system running terminal
37 $(hostname) => $terminalSystem
38 You can give a file to download or a folder to download it in tar.gz.
39 You will be prompted for the target file.
40 -u Upload file from system running terminal to system running shell
41 $terminalSystem => $(hostname)
42 You will be prompted for the source file.
43 I save the file in the given path, or in working directory if path is
44 unspecified, as the same name as source file.
45 If path is not a directory, the I save in it and overwrite if exists.
47 Don't forget to load rxvt extension by Xresouces directive:
48 \"URxvt.perl-ext: default,inbandfiletransfer-osc\"" >&2
60 name
=`readlink -f "$1"`
65 osc2
="$name.tar.gz;-1"
67 size
=`stat -c %s "$1"`
72 osc
"download;base64;$osc2"
75 if [ "$accepted" = "y" ]
79 tar czf
- "$1" 2>/dev
/null | base64
86 echo "File transfer cancelled." >&2
91 echo "Can not read: $1" >&2
105 [ ! -e "$1" ] && wrtbl
=$dir
110 echo "Ready to upload" >&2
114 if [ "$accepted" = "y" ]
128 if [ -z "$size" ] ||
! [ "$size" -ge 0 ] 2>/dev
/null
130 echo "Upload error" >&2
141 done | base64
-d >"$outfile"
146 echo "File transfer completed: $outfile"
148 echo "Error $err" >&2
151 echo "File transfer cancelled." >&2
156 echo "Can not write: $1" >&2