Quantcast
Channel: Intel Communities: Message List
Viewing all articles
Browse latest Browse all 18146

Re: How to set Python Environment prior to login so can run a python program at startup

$
0
0

something like

 

cat > /home/root/display_ip.py <<EOF
#! /usr/bin/env python

import pyupm_i2clcd as lcd
x = lcd.Jhd1313m1(0, 0x3E, 0x62)
import subprocess
ip=subprocess.check_output(["/home/root/ipaddress.sh"]).rstrip()
x.write(ip)
EOF

cat > /home/root/ipaddress.sh <<EOF
ifconfig | grep -A 1 wlan0 | grep  "^.*inet" | awk '{print $2}' | awk -F ":" '{print $2}' #extract IPv4 address
EOF

# cat > /lib/systemd/system/display_ip.service <<EOF
[Unit]
Description=Display IP address
After=network.target multi-user.target connman.service


[Service]
ExecStart=/usr/bin/python /home/root/display_ip.py
Restart=always


[Install]
WantedBy=multi-user.target
EOF

systemctl enable display_ip

 

works for me. Alternatively: you can compute the IPv6 address from the MAC address which is put on a sticker coming with the Edison. With that you could just connect to IPv6.

(display_ip.py just slightly modified from upm/rgb-lcd.py at master · intel-iot-devkit/upm · GitHub; ipaddress.sh could surely be done directly in Python in a nicer way - was just a quick test)


Viewing all articles
Browse latest Browse all 18146

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>