squirreltown
Posts: 10
Joined: Mon Jan 23, 2017 2:08 am

Cloned pi's act different

Thu Feb 16, 2017 5:25 pm

Have two Rp3's setup identically as web servers. Have a python script that runs on startup ( ~/.config/lxsession/LXDE-pi/autostart)
The problem is it only works on one of the two Pi's. I"m new to Linux so I'm looking for what factors I might be missing. The pi that doesn't run the script is a SD card clone of the one that does, no changes.

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Cloned pi's act different

Thu Feb 16, 2017 6:15 pm

How does the original, working, RPi determine its IP address?

(If you have configured it with a static IP address assignment and then cloned that configuration, the clone machine will be unable to join the local IP network due to that address clash.)

[Maybe lots of other reasons for your issue, that's just one that comes to mind.]

squirreltown
Posts: 10
Joined: Mon Jan 23, 2017 2:08 am

Re: Cloned pi's act different

Thu Feb 16, 2017 6:21 pm

Thanks for answering.
Both pi's have i.p. reservations on the router and are connecting fine, no static setup.
Really stumping me. A clone should be a clone right?

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Cloned pi's act different

Thu Feb 16, 2017 6:31 pm

Unless there is anything sensitive in it like passwords that you should obscure, perhaps it would help to post the script itself here? Using [ Code ] markup via the button at the top of the message screen.

Pedantically, that script does not run at startup but when the pi user begins a GUI session. But if the master version works that may not be significant.

PS: just noticed that this seems to be a duplicate of viewtopic.php?f=91&t=174503&p=1114194#p1114194

squirreltown
Posts: 10
Joined: Mon Jan 23, 2017 2:08 am

Re: Cloned pi's act different

Thu Feb 16, 2017 6:45 pm

Yes it's a dupe, I see no option to delete it, this is where i should have put it.
I don't know Python yet, so i know this script is missing some sort of closing tag.
It works fine in the terminal (shows an error but opens the php file OK) and if I click it on the desktop. And again, the other pi launches it just fine on desktop startup.

Code: Select all

#!/usr/bin/python

import subprocess
import socket
def get_ip_address():
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.connect(('8.8.8.8', 80))
    return s.getsockname()[0]

value = get_ip_address() 
script_response = subprocess.Popen(['php', '/home/pi/get_ip.php', value])

print (values)

Return to “Troubleshooting”