Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 启动时通过电子邮件发送raspberry pi IP_Python_Raspberry Pi_Crontab_Raspbian - Fatal编程技术网

Python 启动时通过电子邮件发送raspberry pi IP

Python 启动时通过电子邮件发送raspberry pi IP,python,raspberry-pi,crontab,raspbian,Python,Raspberry Pi,Crontab,Raspbian,我试图让我的RP在WIFI上通过shh访问,但我无法控制我的路由器(我住在学生宿舍),我无法配置静态IP,因此我编写了一个python脚本,将获取当前IP并将其发送到我的gmail帐户。 然后我将脚本添加到crontab 以下是脚本: 问题是脚本返回一个错误: Traceback (most recent call last): File "/home/pi/Programming/python/send_ip_by_mail.py", line 11, in <module>

我试图让我的RP在WIFI上通过shh访问,但我无法控制我的路由器(我住在学生宿舍),我无法配置静态IP,因此我编写了一个python脚本,将获取当前IP并将其发送到我的gmail帐户。 然后我将脚本添加到
crontab

以下是脚本:

问题是脚本返回一个错误:

Traceback (most recent call last):
  File "/home/pi/Programming/python/send_ip_by_mail.py", line 11, in <module>
    ip = socket.inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', 'wlan0'[0:15])[20:24]))
IOError: [Errno 99] Cannot assign requested address
回溯(最近一次呼叫最后一次):
文件“/home/pi/Programming/python/send_ip_by_mail.py”,第11行,在
ip=socket.inet_ntoa(fcntl.ioctl(s.fileno(),0x8915,struct.pack('256s','wlan0'[0:15])[20:24]))
IOError:[Errno 99]无法分配请求的地址
当我自己运行脚本时,它工作得很好,但在启动时就不行了。 有什么问题


谢谢

“启动时”不够精确-你确定在调用脚本时接口已经启动并获得了dhcp地址吗?你的raspi没有向路由器注册主机名吗?@fvu嗯,我想这可能是问题所在,但在我升级raspbian版本之前它一直工作。“不是,它只是抛出了那个错误。”马格德我不知道你说的是什么意思。你能详细说明一下吗?如果你把树莓的主机名注册到路由器上,你可以用它的名字来访问树莓:raspberry.internal.net
Traceback (most recent call last):
  File "/home/pi/Programming/python/send_ip_by_mail.py", line 11, in <module>
    ip = socket.inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', 'wlan0'[0:15])[20:24]))
IOError: [Errno 99] Cannot assign requested address