我创建了一个脚本,我想通过蓝牙发送文件。为此,我采用了“obexctl”实用程序。我可以通过终端使用 obexctl 实用程序传输文件。但是当我尝试使用期望将其合并到脚本中时,它会显示“客户端代理不可用”。
有人可以帮我写代码吗?提前致谢。
终端上的命令:
$ obexctl
[NEW] Client /org/bluez/obex
[obex]# connect xx:xx:xx:xx:xx:xx
Attempting to connect to xx:xx:xx:xx:xx:xx
[NEW] Session /org/bluez/obex/client/session11 [default]
[NEW] ObjectPush /org/bluez/obex/client/session11
Connection successful
[xx:xx:xx:xx:xx:xx]# send abc.txt
Attempting to send abc.txt to /org/bluez/obex/client/session3
[NEW] Transfer /org/bluez/obex/client/session3/transfer1
Transfer /org/bluez/obex/client/session3/transfer1
Status: queued
Name: filename.sh
size: 0
Filename: abc.txt
Session: org/bluez/obex/client/session3
[CHG] Transfer /org/bluez/obex/client/session3/transfer1 Status: complete
[DEL] Transfer /org/bluez/obex/client/session3/transfer1
[xx:xx:xx:xx:xx:xx]#
外壳脚本
#!/bin/bash
....
/usr/bin/expect << EOF
set prompt "#"
spawn sudo obexctl
#expect -re \$prompt
expect "Client"
send "connect $hw_addr\r"
sleep 4
expect "Connection"
send "send $bluetooth_log_file\r"
send "quit\r"
EOF
....
在执行此脚本时,它提供如下输出:
spawn sudo obexctl
[obex]# connect xx:xx:xx:xx:xx:xx
Client proxy not available
[obex]#
结果应该相同,要么在终端上手动执行,要么使用脚本自动执行。
有人可以在我做错的地方提供一些建议。