Main Content

cd

SFTP 또는 FTP 서버에서 현재 폴더 변경 또는 보기

설명

예제

cd(s,folder)s에 연결된 SFTP 또는 FTP 서버에서 현재 폴더를 변경합니다.

cd(s)는 서버의 현재 폴더 경로를 표시합니다.

newFolder = cd(___)는 추가적으로 경로를 문자형 벡터로 반환합니다. 위에 열거된 구문 중 하나의 입력 인수를 사용할 수 있습니다. 첫 번째 구문을 사용할 경우, newFolder는 폴더를 변경한 후의 경로입니다.

예제

모두 축소

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의 출력값은 현재 MATLAB 폴더가 아닌 SFTP 서버에 있는 현재 폴더의 경로입니다.

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 서버의 대상 폴더 이름으로, 문자형 벡터 또는 string형 스칼라로 지정됩니다. 현재 폴더의 상위 폴더를 지정하려면 '..'를 사용하십시오.

  • 로그인 폴더로 이동하려면 cd 함수에 ~ 기호를 전달하십시오.

버전 내역

R2006a 이전에 개발됨

참고 항목

| |