0

当我 ssh 进入我的 dd-wrt ​​路由器并发出命令时,我的以下脚本运行良好

/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

但是当我通过 GUI 发出相同的命令时;管理/命令然后相同的脚本不起作用。

任何可行的解决方案都会有很大的帮助,谢谢

4

1 回答 1

2

登录机器并输入命令:

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
于 2013-11-16T18:32:45.123 回答