简体   繁体   English

使用sftp在本地计算机(Linux)中创建目录

[英]Create directory in local machine(Linux) by using sftp

I have tried the command below to create a directory after I downloaded a file from sftp. 从sftp下载文件后,我尝试使用以下命令创建目录。 But unfortunately the command couldn't run. 但不幸的是,该命令无法运行。 What's the error between this command? 这个命令之间有什么错误?

sftp username@servername:/server/path/xxx.txt lmkdir /my/home/directory/new_path

to create a directory just use 创建目录只是使用

lmkdir  dirName

http://www.bic.mni.mcgill.ca/users/kate/Howto/sftp_notes.html http://www.bic.mni.mcgill.ca/users/kate/Howto/sftp_notes.html

jimmy@moody:~$ sftp localhost 
The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is 97:52:17:f7:e7:c4:5b:68:00:62:6d:42:2c:ee:5a:60.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
jimmy@localhost's password: 
Connected to localhost.
sftp> lmkdir dirName
sftp> exit
jimmy@moody:~$ ls dirName/

lmkdir path lmkdir路径

         Create local directory specified by path.

Also you might want to use 另外你可能想使用

lcd path LCD路径

         Change local directory to path.

lls [ls-options [path]] lls [ls-options [路径]]

         Display local directory listing of either path or current directory if path is not specified.  ls-options
         may contain any flags supported by the local system's ls(1) command.  path may contain glob(3) characters
         and may match multiple files.

The command you are invoking is invalid. 您正在调用的命令无效。 As others here have mentioned the command to create a local directory while in the sftp shell is lmkdir, however you are not invoking the shell, you are trying to copy the file into a directory while creating the directory. 正如这里的其他人提到的那样,在sftp shell中为lmkdir时创建本地目录的命令,但是您没有调用该Shell,而是在创建目录时尝试将文件复制到目录中。

The way your current command is being interpreted is as a request to download "servername:/server/path/xxx.txt" into a file called "lmkdir" followed by an invalid option of "/my/home/directory/new_path" which sftp doesn't understand. 当前命令的解释方式是请求将“ servername:/server/path/xxx.txt”下载到名为“ lmkdir”的文件中,然后再输入“ / my / home / directory / new_path”无效的选项sftp不明白。

What you want to do instead is 您要做的是

mkdir /my/home/directory/new_pathsftp
sftp username@servername:/server/path/xxx.txt /my/home/directory/new_pathsftp

or from the sftp shell: 或从sftp shell:

$ sftp username@servername
Connected to username@servername
sftp> lmkdir /my/home/directory/new_pathsftp
sftp> lcd /my/home/directory/new_pathsftp
sftp> get /server/path/xxx.txt
sftp> quit

You can include the three lines executed in the sftp shell as a batch file to be executed when connected, eg 您可以将在sftp shell中执行的三行包含为连接时要执行的批处理文件,例如

sftp username@servername -b batchfile

where batchfile contains the following 其中batchfile包含以下内容

lmkdir /my/home/directory/new_pathsftp
lcd /my/home/directory/new_pathsftp
get /server/path/xxx.txt
quit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM