mget
SFTP 또는 FTP 서버에서 파일 다운로드
설명
downloadPaths = mget(___)
은 다운로드한 파일과 폴더의 경로를 문자형 벡터로 구성된 셀형 배열로 반환합니다. 위에 열거된 구문 중 하나의 입력 인수를 사용할 수 있습니다.
예제
파일 다운로드하기
FTP 서버에서 텍스트 파일을 다운로드하고 해당 파일의 내용을 표시합니다.
먼저, NCEI(National Centers for Environmental Information) FTP 서버에 연결합니다.
s = 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: "/"
텍스트 파일을 다운로드합니다. mget
함수는 파일을 컴퓨터의 현재 폴더에 다운로드합니다.
mget(s,'README.txt');
README.txt
의 시작 부분을 표시합니다. 컴퓨터에 다운로드한 README.txt
의 복사본을 읽으려면 fileread
함수를 사용하십시오.
readme = fileread('README.txt');
readme(1:95)
ans = ' Welcome to the NOAA/National Centers for Environmental Information (NCEI)'
NCEI(National Centers for Environmental Information)에서 제공하는 FTP 서비스입니다. NCEI 서비스 약관을 보려면 NCEI Privacy Policy, Disclaimer, and Copyright를 참조하십시오.
파일을 지정된 폴더에 다운로드하기
FTP 서버의 텍스트 파일을 로컬 컴퓨터의 지정된 폴더에 다운로드합니다.
먼저, NCEI(National Centers for Environmental Information) FTP 서버에 연결합니다.
s = 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: "/"
텍스트 파일을 myLocalFolder
폴더에 다운로드합니다. 이 폴더가 존재하지 않을 경우 mget
함수가 로컬 컴퓨터에 이 폴더를 만듭니다.
mget(s,'README.txt','myLocalFolder');
fileread
함수를 사용하여 README.txt
의 시작 부분을 읽어옵니다.
readme = fileread('myLocalFolder/README.txt');
readme(1:95)
ans = ' Welcome to the NOAA/National Centers for Environmental Information (NCEI)'
NCEI(National Centers for Environmental Information)에서 제공하는 FTP 서비스입니다. NCEI 서비스 약관을 보려면 NCEI Privacy Policy, Disclaimer, and Copyright를 참조하십시오.
입력 인수
s
— SFTP 또는 FTP 서버와의 연결
SFTP 객체 | FTP 객체
SFTP 또는 FTP 서버와의 연결로, SFTP 객체 또는 FTP 객체로 지정됩니다.
contents
— 원격 파일 또는 폴더
문자형 벡터 | string형 스칼라
원격 파일 또는 폴더로, 문자형 벡터 또는 string형 스칼라로 지정됩니다.
SFTP 또는 FTP 서버에서 여러 개의 파일이나 폴더에 일치시키기 위해 contents
에 와일드카드 문자(*
)를 포함할 수 있습니다. 예를 들어, contents
를 *.docx
로 지정하면 mget
은 이름이 .docx
로 끝나는 모든 파일을 다운로드합니다.
target
— 로컬 폴더
문자형 벡터 | string형 스칼라
로컬 폴더로, 문자형 벡터 또는 string형 스칼라로 지정됩니다. target
은 절대 경로나 상대 경로를 지정할 수 있습니다.
버전 내역
R2006a 이전에 개발됨
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)