# 执行蓝牙 FTP 客户端功能

Source: [https://docs.qualcomm.com/doc/80-70017-13SC/topic/bluez-perform-bluetooth-ftp-server-and-client-functions.html](https://docs.qualcomm.com/doc/80-70017-13SC/topic/bluez-perform-bluetooth-ftp-server-and-client-functions.html)

用户可以使用 obexctl 主菜单中提供的命令验证蓝牙 FTP 客户端功能。

注释： 要测试或验证 FTP 服务器功能，无需测试应用程序。通过客户端连接来执行 FTP 功能。

开始之前，请按照[设置设备的蓝牙 FTP 功能](https://docs.qualcomm.com/doc/80-70017-13SC/topic/bluez-ftp.html#bluez-ftp__section_bdh_4fl_rcc_navyanka_09-11-24-025-48-587)中的说明设置设备。

## 创建文件夹

要在远程设备上创建文件夹，请从 `obexctl` 菜单运行以下命令：

    mkdir <folder_name>Copy to clipboard

用户可以验证服务器上 /var/bluetooth 目录中的文件夹创建情况。

**参数**

`<folder_name>` 是新文件夹名称。

**示例**

请运行以下命令，以便创建名为 new\_dir 的文件夹：

    mkdir new_dirCopy to clipboard

**示例输出**

#mkdir new_dir
    Attempting to CreateFolder
    CreateFolder successfulCopy to clipboard

## 更改当前文件夹

要更改远程设备的当前文件夹，请从 `obexctl` 菜单运行以下命令：

    cd <folder_path>Copy to clipboard

**参数**

`<folder_path>` 是您打算切换至的文件夹。

**示例**

要将当前文件夹更改为 new\_dir，请运行以下命令：

    cd new_dirCopy to clipboard

**示例输出**

#cd new_dir
    Attempting to ChangeFolder to new_dir
    ChangeFolder successfulCopy to clipboard

## 获取当前文件夹信息

要获取有关当前文件夹的信息，请从 `obexctl` 菜单运行以下命令：

    ls .Copy to clipboard

**示例输出**

# ls .
    Attempting to ListFolder
    [NEW] Transfer /org/bluez/obex/client/session7/transfer4
    [CHG] Transfer /org/bluez/obex/client/session7/transfer4 Size: 611
    [CHG] Transfer /org/bluez/obex/client/session7/transfer4 Status: complete
          Type: folder
           Name: My_folder
           User-perm: RWD
           Group-perm: R
           Other-perm:
           Accessed: 20231214T123503Z
           Modified: 20231214T123502Z
           Created: 20231214T123502Z
           Type: folder
           Name: new_dir
           User-perm: RWD
           Group-perm: R
           Other-perm:
           Accessed: 20231215T093311Z
           Modified: 20231215T093245Z
           Created: 20231215T093245ZCopy to clipboard

## 将文件复制至远程设备

要将本地文件复制到远程设备，请从 `obexctl` 菜单运行以下命令：

    cp :<source_file> <destination_file>Copy to clipboard

**参数**

- `<source_file>` 是本地文件。
- `<destination_file>` 是远程设备上的目标文件。

**示例**

要将 Documents/ftp\_client.txt 处的本地文件复制到远程设备上的 ftp\_client.txt，请运行以下命令：

    cp :Documents/ftp_client.txt ftp_client.txtCopy to clipboard

**示例输出**

# cp :Documents/ftp_client.txt ftp_client.txt
    Attempting to PutFile
    [NEW] Transfer /org/bluez/obex/client/session7/transfer5
    Transfer /org/bluez/obex/client/session7/transfer5
          Status: queued
           Name: ftp_client.txt
           Size: 10
           Filename: Documents/ftp_client.txt
           Session: /org/bluez/obex/client/session7
    [CHG] Transfer /org/bluez/obex/client/session7/transfer5 Status: complete
    [DEL] Transfer /org/bluez/obex/client/session7/transfer5Copy to clipboard

## 从远程设备复制文件

开始之前，[将当前文件夹](https://docs.qualcomm.com/doc/80-70017-13SC/topic/bluez-perform-bluetooth-ftp-server-and-client-functions.html#bluez-perform-bluetooth-ftp-server-and-client-functions__section_h1b_y3l_rcc_navyanka_09-11-24-051-31-148)更改为所需文件的文件夹。

要将文件从远程设备复制到本地目录，请从 `obexctl` 菜单运行以下命令：

    cp <destination_file> :<source_file>Copy to clipboard

**参数**

- `<source_file>` 是远程设备上的文件。
- `<destination_file>` 是本地设备上的目标文件。

**示例**

要将 ftp\_client\_2.txt 文件从远程设备复制到本地设备，请运行以下命令：

    cp ftp_client_2.txt :ftp_client_2.txtCopy to clipboard

**示例输出**

# cp ftp_client_2.txt :ftp_client_2.txt
    Attempting to GetFile
    [NEW] Transfer /org/bluez/obex/client/session7/transfer21
    Transfer /org/bluez/obex/client/session7/transfer21
           Status: queued
           Name: ftp_client_2.txt
           Size: 0
           Filename: ftp_client_2.txt
           Session: /org/bluez/obex/client/session7
    [CHG] Transfer /org/bluez/obex/client/session7/transfer21 Size: 13
    [CHG] Transfer /org/bluez/obex/client/session7/transfer21 Status: complete
    [DEL] Transfer /org/bluez/obex/client/session7/transfer21Copy to clipboard

## 在远程设备中复制文件

要将文件从远程设备上的一个目录复制到另一个目录，请从 `obexctl` 菜单运行以下命令：

    cp <source_file> <destination_file>Copy to clipboard

**参数**

- `<source_file>` 是待复制的文件。
- `<destination_file>` 为目标位置。

**示例**

要将 ftp\_client.txt 复制到 /new\_dir\_2/，请运行以下命令：

    cp ftp_client.txt ../new_dir_2/ftp_client.txtCopy to clipboard

**示例输出**

# cp ftp_client.txt ../new_dir_2/ftp_client.txt
    Attempting to CopyFile
    CopyFile successfulCopy to clipboard

## 移动文件

要将文件从一个文件夹移动到另一个文件夹，请从 `obexctl` 菜单运行以下命令：

    mv <source_file> <destination_file>Copy to clipboard

**参数**

- `<source_file>` 是待移动的文件。
- `<destination_file>` 为目标位置。

**示例**

要将 ftp\_client\_2.txt 文件移动到 /new\_dir\_2/，请运行以下命令：

    mv ftp_client_2.txt ../new_dir_2/ftp_client_2.txtCopy to clipboard

**示例输出**

#mv ftp_client_2.txt ../new_dir_2/ftp_client_2.txt
    Attempting to MoveFile
    MoveFile successfulCopy to clipboard

## 删除文件

要删除文件，请从 `obexctl` 菜单运行以下命令：

    rm <filename>Copy to clipboard

**参数**

`<filename>` 是待删除的文件。

**示例**

要删除 `ftp_client.txt` 文件，请运行以下命令：

    rm ftp_client.txtCopy to clipboard

**示例输出**

# rm ftp_client.txt
    Attempting to Delete
    Delete successfulCopy to clipboard

**上一级主题：** [文件传输协议](https://docs.qualcomm.com/doc/80-70017-13SC/topic/bluez-ftp.html)

Last Published: Jan 23, 2025

[Previous Topic
文件传输协议](https://docs.qualcomm.com/bundle/publicresource/80-70017-13SC/topics/bluez-ftp.md) [Next Topic
电话簿访问配置文件](https://docs.qualcomm.com/bundle/publicresource/80-70017-13SC/topics/bluez-pbap.md)