ascii
FTP 転送モードを ASCII に設定
説明
例
ASCII 転送モードを使用して、FTP サーバーからテキスト ファイルをダウンロードします。
まず、National Centers for Environmental Information (NCEI、米国環境情報センター) の FTP サーバーに接続します。
ftpobj = ftp('ftp.ngdc.noaa.gov')
FTP with properties: Host: "ftp.ngdc.noaa.gov" Username: "anonymous" Port: 21 ServerLocale: "en_US" DirParserFcn: @matlab.io.ftp.parseDirListingForUnix Mode: "binary" LocalDataConnectionMethod: "passive" RemoteWorkingDirectory: "/" CertificateFilename: "default" ConnectionTimeout: 5 min TransferTimeout: Inf sec
既定の転送モードはバイナリです。テキスト ファイルをダウンロードする場合、代わりに ASCII モードを使用できます。これにより改行文字が正しく変換されます。
転送モードを ASCII に設定します。現在の転送モードを表示するために、FTP オブジェクトを表示します。
ascii(ftpobj) ftpobj
FTP with properties: Host: "ftp.ngdc.noaa.gov" Username: "anonymous" Port: 21 ServerLocale: "en_US" DirParserFcn: @matlab.io.ftp.parseDirListingForUnix Mode: "ascii" LocalDataConnectionMethod: "passive" RemoteWorkingDirectory: "/" CertificateFilename: "default" ConnectionTimeout: 5 min TransferTimeout: Inf sec
テキスト ファイルをダウンロードして接続を切断します。
mget(ftpobj,'README.txt');
close(ftpobj)
README.txt
の先頭を表示します。コンピューターにダウンロードした README.txt
のコピーを読み取るには、関数 fileread
を使用します。
readme = fileread('README.txt');
readme(1:95)
ans = ' Welcome to the NOAA/National Centers for Environmental Information (NCEI)'
FTP サービスは National Centers for Environmental Information (NCEI、米国環境情報センター) により提供されています。NCEI の利用規約は、NCEI Privacy Policy, Disclaimer, and Copyright を参照してください。
入力引数
FTP サーバーへの接続。FTP オブジェクトとして指定します。
バージョン履歴
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.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)