登录机器并输入命令:
which sh
将此值作为第一行,在其前面加上 #! 字符,比如
#!/bin/sh
你的外壳版本是什么?通过 ssh 连接到路由器后,请仔细查看第一行。它类似于:
BusyBox v1.15.3 (2011-11-24 00:44:20 CET) built-in shell (ash)
Enter 'help' for a list of built-in commands.
您可能希望记录命令的输出以进行调试:
#!/bin/sh
/opt/bin/curl --url "smtps://smtp.gmail.com:465" --ssl-reqd --mail-from "username@gmail.com" --mail-rcpt "username@gmail.com" --upload-file /mnt/mail.txt --user "username@gmail.com:password" --insecure 2>&1 | logger -t $0
它将使用 syslog 工具记录输出。如果发生这种情况,您没有安装 syslog,您可以将输出记录到文件中:
#!/bin/sh
/opt/bin/curl --url "smtps://smtp.gmail.com:465" --ssl-reqd --mail-from "username@gmail.com" --mail-rcpt "username@gmail.com" --upload-file /mnt/mail.txt --user "username@gmail.com:password" --insecure >> /tmp/mylogfile 2>&1
另外,请确保脚本具有可执行属性集:
chmod a+rx /path/to/your/script