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 より前に導入

参考

| |