查看“︁Fup and d”︁的源代码
←
Fup and d
跳转到导航
跳转到搜索
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:{{spmono|fup}} and {{spmono|d}}}} This is a pair of Windows Batch scripts that was initially created with the intention of uploading to and downloading from a fixed FTP address with pre-written sign-in credentials—based on a quick conceit that was originally conceived as a way of passing small files back and forth through a private FTP server. They were later both added with a switch to directly delete from the fixed FTP server, and the latter was then also subsequently expanded its download function to accept more general URLs. To use this batch, the following parts of the script must be properly filled out first: * In line {{spmono|18}} of {{spmono|fup.bat}} and line {{spmono|35}} of {{spmono|d.bat}}, the part ‘{{spmono|…}} <syntaxhighlight lang="winbatch" inline>set "u=https://your.file-HTTP.com/%%a"</syntaxhighlight>’ shall be filled with your actual HTTP base link to your file, which may or may not be the same as the FTP address to where you upload your file based on your server-side settings; and * In lines {{spmono|20}} and {{spmono|22}} of {{spmono|fup.bat}} and line {{spmono|96}} of {{spmono|d.bat}}, you’ll need to change the part ‘<code><nowiki>ftp://your.file-FTP.com/ --user USERNAME:PASSWORD</nowiki></code>’ to fill in your real FTP address and your sign-in credentials; and * the character count in line {{spmono|96}} of {{spmono|d.bat}} obviously needs to be changed accordingly to be consistent with your HTTP base link. Then, simply use <code>'''fup''' "file-to-upload.ext"</code> to upload the file to the fixed FTP and get an HTTPS link ''(needs server-side support)'' to the file both on screen and in the clipboard, or use <code>'''d''' "<nowiki>https://some.domain.here/link-to-the-file.ext</nowiki>"</code> to download the file from the given link. When uploading to the FTP using <code>fup</code>, the filename ''must'' be kept simple, preferably only consisting of [[wikipedia:Basic_Latin_(Unicode_block)|Basic Latin]] '''letters''' ({{spmono|<nowiki>[</nowiki>A-z<nowiki>]</nowiki>}}) and '''digits''' ({{spmono|<nowiki>[</nowiki>0-9<nowiki>]</nowiki>}}) (with hyphens <nowiki>[</nowiki><code>'''-'''</code><nowiki>]</nowiki> and/or underscores <nowiki>[</nowiki><code>'''_'''</code><nowiki>]</nowiki> being used to separate words). Although it can process filenames with CJK characters located within the same code page as the system’s Locale (for reasons I cannot fully understand, <code>chcp 65001</code> is not effective here), it might cause difficulties for the recipient while downloading. Similarly, files with spaces in their filenames can be successfully uploaded (and then be downloaded by the recipient with the auto-generated links); it is strongly discouraged to do so as files uploaded with spaces in names cannot be deleted from the FTP server with <code>curl -Q</code>. Additionally, filenames consisting of apostrophes (<code><b>'</b></code>) will ''always'' fail to upload. When downloading files using <code>d</code>, by default, the script will download the file from the given link to the current folder with the name in the link. But on many an occasion, the name in the link might have been [[wikipedia:percent-encoding|per cent–encoded]]. To address this, a switch <code>'''-n'''</code> is created and can therefore be passed to the script to ‘normalise’ the name—it probably would be more appropriate to go by ‘decode’, and yet the <code>-d</code> switch has already been taken for ‘delete’. Use <code>'''-p'''</code> to direct the location for the file to be saved (while still using the default name, whether normalised or not, which is controlled by the <code>-n</code> switch), and use <code>'''-o'''</code> to designate the path ''and'' the filename. These two switches should not be used together, but if they were to be used together, the script should normally still work. If a backtick (<code>'''`'''</code>) is detected after the <code>-p</code> switch, whether it is located at the beginning of the string after <code>-p</code> or whether it is the exact content of the entire string, it will be replaced with the default location for downloads (here in my case is <code>D:\Omnigena\</code>). If a backtick (<code>'''`'''</code>) is detected after the <code>-o</code> switch and if no <code>-p</code> switch is passed to the script, then the backtick at the beginning of the string after <code>-o</code>, if exists, will be replaced with the default location for downloads, with all the rest backticks ''(if exist)'' in the string being replaced with the normalised default name, with two more compound keywords for replacement are responsive: <code>'''`b'''</code> stands for the basename of the normalised default name and <code>'''`x'''</code> stands for the extension of the normalised default name. If <code>-p</code> and its value string are also present and are passed together with <code>-o</code>, then the backtick at the beginning of the string after <code>-o</code> ''(if exists)'' will not be parsed as the default location for downloads; rather, it will be replaced with the normalised default name, just as the other backticks ''(if exist)'' in the rest of the string. Pass <code>'''-d'''</code> to either <code>'''fup'''</code> or <code>'''d'''</code> will all perform the same task—delete the file from the fixed FTP server. But for <code>'''fup'''</code>, the name of the file to be deleted from the FTP server must be passed as is (wrapping it in dumb double quotes if it contains space or spaces of course); it cannot accept links or per cent–encoded names; while the <code>'''d'''</code> deals with this more flexibly by allowing links. The reason for this difference and the reason why I added a <code>-d</code> switch to <code>'''fup'''</code>—a batch script that is created for the uploading of files, is that I can now comfortably press {{spk|F3}} to summon my last command and add a simple <code>-d</code> to it and then press {{spk|RETURN}} to delete the file once the recipient finishes the downloading. The <code>-d</code> switch for <code>'''d'''</code> obviously only works for those links derived from the fixed FTP server—after all, we cannot delete files from places over which we have no control. Additionally, if the name in the link consists of apostrophes (<code><b>'</b></code>), then it will ''always'' fail to download, too. The current script cannot address this problem. <hr /> A pair of untested [[wikipedia:Grok_(chatbot)|Grok]]-translated Linux bash scripts that should function the same as these two Windows batches is enclosed at the end (months later, their [[#And_a_zsh_diversion|{{spmono|zsh}} versions]] are also added). As explained in [[7pk|{{spmono|7pk}}]], what a backtick (<code>'''`'''</code>) represents in the Windows batches is represented by an equals sign (<code>'''='''</code>) in the Linux bash scripts. And the Linux version of {{spmono|d}} diverts the default download path to simply the user’s download folder. ==The batches== <div style="margin: 0.7em 0 0.92em;">{{NB|These two batches use [[wikipedia:CURL|{{spmono|curl}}]], which has only been shipped natively since [[wikipedia:Windows_10,_version_1803|Windows 10 1803]]; for earlier versions of Windows—as early as [[wikipedia:Windows_Vista|Windows Vista]]—you’ll have to download [https://curl.se/windows/latest.cgi?p{{=}}win64-mingw.zip {{spmono|curl}}] and put it into {{spmono|%PATH%}} first.}}</div> {{fup-win}} {{d-win}} ==The bash scripts== <div style="margin: 0.7em 0 0.92em;">{{NB|The following bash script requires [https://packages.debian.org/stable/xclip {{spmono|xclip}}], which can be installed with <syntaxhighlight lang="bash" inline>sudo apt install xclip</syntaxhighlight> on Debian-based Linux distros if not already pre-installed.}}</div> {{fup-linux}} {{d-linux}} ==And a [[wikipedia:Z_shell|{{spmono|zsh}}]] diversion== (Translated by Grok, not fully tested, should be fine.) {{fup-zsh}} {{d-zsh}}
此页面嵌入的页面:
Template:D-linux
(
查看源代码
)
Template:D-win
(
查看源代码
)
Template:D-zsh
(
查看源代码
)
Template:Fup-linux
(
查看源代码
)
Template:Fup-win
(
查看源代码
)
Template:Fup-zsh
(
查看源代码
)
Template:NB
(
查看源代码
)
Template:Spk
(
查看源代码
)
Template:Spmono
(
查看源代码
)
Template:Stbgn
(
查看源代码
)
Template:Stblu
(
查看源代码
)
Template:Stsbl
(
查看源代码
)
返回
Fup and d
。
导航菜单
个人工具
登录
命名空间
页面
讨论
不转换
不转换
简体
繁體
大陆简体
香港繁體
澳門繁體
大马简体
新加坡简体
臺灣正體
查看
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
工具
链入页面
相关更改
页面信息