cd
更改或查看 SFTP 或 FTP 服务器上的当前文件夹
说明
示例
通过创建 SFTP 对象打开与 SFTP 服务器的连接。使用 SFTP 对象列出服务器上子文件夹的内容。在 SFTP 会话结束后,关闭连接。
首先,连接到示例 SFTP 服务器。
s = sftp("sftp.example_galapagos.net","jsmith")
SFTP with properties: Host: "sftp.example_galapagos.net" Username: "jsmith" Port: 22 ServerSystem: "unix" DatetimeType: "datetime" ServerLocale: "en_US" DirParserFcn: @matlab.io.ftp.parseDirListingForUnix RemoteWorkingDirectory: "/home/jsmith"
列出顶层文件夹的内容。
dir(s)
air_quality fish insects README.txt birds INDEX.txt mammals reptiles climate index.html rainfall sftp.html
使用 dir
函数列出子文件夹的内容。
dir(s,"home/jsmith/birds")
albatrosses ducks herons parrots avocets_stilts falcons kingfishers pelicans barn_owls flamingos mockingbirds penguins blackbirds frigatebirds nightjars pheasants boobies grebes northern_storm_petrels pigeons cardinal grosbeaks guineafowl osprey plovers cormorants gulls owls rails cuckoos hawks oystercatcher sandpipers
使用 cd
函数切换到子文件夹。cd
的输出是 SFTP 服务器上当前文件夹的路径,而不是当前 MATLAB 文件夹的路径。
cd(s,"home/jsmith/birds/herons")
ans = "home/jsmith/birds/herons"
列出当前文件夹的内容。
dir(s)
documentation great_egret_data migration_patterns great_blue_heron_data green_heron_data nesting_behaviors
关闭与 SFTP 服务器的连接。您也可以通过删除 SFTP 对象或让连接超时来关闭连接。
close(s)
输入参数
与 SFTP 或 FTP 服务器的连接,指定为 SFTP 对象或 FTP 对象。
SFTP 或 FTP 服务器上的目标文件夹的名称,指定为字符向量或字符串标量。要指定当前文件夹的上一级文件夹,请使用 '..'
。
提示
将
~
符号传递给cd
函数以导航到登录文件夹。
版本历史记录
在 R2006a 之前推出
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)