上述程序提示 line 9: illegal option -d
时间: 2024-02-21 21:00:08 浏览: 36
抱歉,我的错误。`read`命令在某些系统上不支持`-d`选项。您可以尝试使用以下修改过的脚本来解决这个问题:
```bash
#!/bin/bash
# 打开串口
exec 3<> /dev/ttyS0
# 等待登录提示
while read -t 1 -n 1 input <&3; do
if [[ $input == $'\r' ]]; then
break
fi
sleep 0.1
done
# 输入用户名
echo -n "root" >&3
echo "root"
# 等待密码提示
while read -t 1 -n 1 input <&3; do
if [[ $input == $'\r' ]]; then
break
fi
sleep 0.1
done
# 输入密码
echo -n "8498450" >&3
echo "8498450"
```
在这个修改后的脚本中,我们使用了`while`循环和`if`语句来等待和解析串口输出。当检测到回车符`\r`时,我们跳出循环并执行后续的输入操作。这样可以避免使用`-d`选项,从而使脚本更加兼容。
相关问题
rm: illegal option -- / usage: rm [-f | -i] [-dIPRrvWx] file ... unlink [--] file
This error message is indicating that the user has used an illegal option while trying to execute the "rm" or "unlink" command. In this case, the user has used the "/" option which is not recognized by the command.
The correct usage of the "rm" command is:
rm [-f | -i] [-dIRrvWx] file ...
The correct usage of the "unlink" command is:
unlink [--] file
To resolve this error, the user should review their command and remove the "/".
-test: Illegal option -w Usage: hadoop fs [generic options] -test -[defsz] <path>
非常抱歉,我之前的回答有误。您可以使用以下命令检查是否有写入权限:
```
hdfs dfs -test -w hdfs://master01:9000/user/hive/warehouse/dongdb.db/book_1 && echo "writable" || echo "not writable"
```
这个命令会在终端中输出 "writable" 或 "not writable" 的消息,表示您是否有写入权限。如果您有写入权限,终端将输出 "writable",否则将输出 "not writable"。
如果您仍然没有写入权限,您可以尝试使用管理员身份进行操作,或者联系系统管理员进行操作。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![text/x-c++](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)