manleypv
Posts: 11
Joined: Thu Oct 08, 2015 11:48 am

FTP from Pi to PC without internet?

Wed Oct 21, 2015 5:10 pm

Hello all!

I have a script running on the Pi 2 that takes an image, opens ftpserver and puts image on PC, deletes image from Pi, and the cycle repeats at a determined interval.

I've had success doing this at home over WiFi (with internet) but need to replicate this in a university greenhouse, as well as add a number of Pis to the process. I'm in lab now using a router from home (no internet access) so most variables are the same. I can SSH via putty from PC to Pi and connect to the Pi via Filezilla, though both are a bit slower without an actual internet connection.

When I manually run the imaging script, I get:

Code: Select all

Taking picture...
FTP..."imagename"
ftp: connect: Connection timed out
Not connected
Not connected
Not connected
Not connected
Not connected
rm: cannot remove '*.jpg': No such file or directory
Done!
I assume FTP is possible without an actual internet connection. Again, from PC to Pi I can talk but it lags a bit and FTP from Pi to PC times out.

Thanks in advance!

drgeoff
Posts: 10669
Joined: Wed Jan 25, 2012 6:39 pm

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 5:35 pm

Yes, if PC and RPi are connected by ethernet or WiFi on the same LAN, then ftp is possible without a connection to the WAN.

What is the IP address of the PC? What is the IP address of the RPi?

JimmyN
Posts: 1109
Joined: Wed Mar 18, 2015 7:05 pm
Location: Virginia, USA

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 5:39 pm

Just spitballing here, but if you're doing all this locally (no internet) I'd try creating a shared folder on the PC. Then mount that folder on each RPi. When the RPi takes a picture just have the script move the picture over to the shared folder.

Or possibly have the RPi save the picture to the shared folder to begin with, so it wouldn't have to be moved. You wouldn't need SSH, FTP, Filezilla or anything else. You would need to install "ntfs-3g" on the RPi so it can write to a NTFS (Windows) filesystem.

manleypv
Posts: 11
Joined: Thu Oct 08, 2015 11:48 am

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 5:53 pm

drgeoff wrote:Yes, if PC and RPi are connected by ethernet or WiFi on the same LAN, then ftp is possible without a connection to the WAN.

What is the IP address of the PC? What is the IP address of the RPi?
PC - 192.168.2.3
RPi - 192.168.2.5

The imaging script is:

Code: Select all

sendpic () {
        picopts="-q 100 -sh 11 -br 60 -awb off -mm matrix -co 20 -ISO 0"
        picsize="-w 1280 -h 1040"
        datets=$(date +%s)
        filename="img$datets.jpg"
        curpic="current.jpg"
        ftpserver="192.168.2.3"
        ftpdir="RPI1"
        ftpuser="pi"
        ftppass="xxxxxxx"

        echo "Taking picture..."
#       raspistill -o $filename
        raspistill $picopts -o $filename $picsize
echo "FTP... $filename"

 echo "
 open $ftpserver
 user $ftpuser $ftppass
 binary
 cd $ftpdir
 put $filename
 put $filename $curpic
 bye
 " | ftp -n

        rm *.jpg

        echo "Done!"
}

starthour=7
stophour=16

if [ $(date +%H) -le $stophour ]; then
  if [ $(date +%H) -ge $starthour ]; then
    sendpic
  fi
fi
FileZilla server is set to allow pi user.

manleypv
Posts: 11
Joined: Thu Oct 08, 2015 11:48 am

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 5:54 pm

JimmyN wrote:Just spitballing here, but if you're doing all this locally (no internet) I'd try creating a shared folder on the PC. Then mount that folder on each RPi. When the RPi takes a picture just have the script move the picture over to the shared folder.

Or possibly have the RPi save the picture to the shared folder to begin with, so it wouldn't have to be moved. You wouldn't need SSH, FTP, Filezilla or anything else. You would need to install "ntfs-3g" on the RPi so it can write to a NTFS (Windows) filesystem.
I initially was going the shared folder route with some luck, couldn't get the shared folder to mount automatically on boot.

Would it be

Code: Select all

sudo apt-get install ntfs-3g
?

I'm really new to all this.

drgeoff
Posts: 10669
Joined: Wed Jan 25, 2012 6:39 pm

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 7:09 pm

manleypv wrote:I can SSH via putty from PC to Pi and connect to the Pi via Filezilla,..
But have you tested in the reverse direction? Eg if on the RPi you type

Code: Select all

ping 192.168.2.3
what do you get?
(If you don't have keyboard and display on the RPi you can ssh from the PC to RPi and use the PC's keyboard and display to run the ping command on the RPi.)

manleypv
Posts: 11
Joined: Thu Oct 08, 2015 11:48 am

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 7:11 pm

drgeoff wrote:
manleypv wrote:I can SSH via putty from PC to Pi and connect to the Pi via Filezilla,..
But have you tested in the reverse direction? Eg if on the RPi you type

Code: Select all

ping 192.168.2.3
what do you get?
(If you don't have keyboard and display on the RPi you can ssh from the PC to RPi and use the PC's keyboard and display to run the ping command on the RPi.)
Currently pinging 64 bytes around 7 ms, at 85 times now and counting.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 7:26 pm

You would need to install "ntfs-3g" on the RPi so it can write to a NTFS (Windows) filesystem.
No.

Since you are going through Samba, you don't need (or want) to have ntfs-3g installed on the Pi.

P.S. The advice to install that driver would only apply if you were going to plug the Windows-formatted disk directly into the Pi (i.e., via USB).
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

manleypv
Posts: 11
Joined: Thu Oct 08, 2015 11:48 am

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 7:27 pm

Joe Schmoe wrote:
You would need to install "ntfs-3g" on the RPi so it can write to a NTFS (Windows) filesystem.
No.

Since you are going through Samba, you don't need (or want) to have ntfs-3g installed on the Pi.

P.S. The advice to install that driver would only apply if you were going to plug the Windows-formatted disk directly into the Pi (i.e., via USB).
I ran

Code: Select all

sudo apt-get install ntfs-3g
and it was already installed anyway.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 7:31 pm

I ran

Code: Select all

sudo apt-get install ntfs-3g
and it was already installed anyway.
That's not surprising. But the fact remains that you don't need it for Samba to work. I was just advising the poster who claimed otherwise.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

drgeoff
Posts: 10669
Joined: Wed Jan 25, 2012 6:39 pm

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 7:32 pm

Are you sure that the ftp server on the PC is running? And listening on the 192.168.2.3 address? :)

manleypv
Posts: 11
Joined: Thu Oct 08, 2015 11:48 am

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 7:36 pm

drgeoff wrote:Are you sure that the ftp server on the PC is running? And listening on the 192.168.2.3 address? :)
Definitely running. Set to run on boot. I set up FileZilla server and router using these instructions: https://avjacobsen.wordpress.com/2012/1 ... sive-mode/

Worked at home on a netgear router. Brought a belkin with me to school to work, followed same instructions. No dice.

drgeoff
Posts: 10669
Joined: Wed Jan 25, 2012 6:39 pm

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 7:42 pm

If you have the RPi and PC on the same LAN subnet (and the IP addresses you quoted imply that they are) then there is no NAT involved and those instructions are irrelevant.

manleypv
Posts: 11
Joined: Thu Oct 08, 2015 11:48 am

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 7:43 pm

drgeoff wrote:If you have the RPi and PC on the same LAN (and the IP addresses you quoted imply that they are) then there is no NAT involved and those instructions are irrelevant.
I'm using wifi.

drgeoff
Posts: 10669
Joined: Wed Jan 25, 2012 6:39 pm

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 7:43 pm

manleypv wrote:
drgeoff wrote:If you have the RPi and PC on the same LAN (and the IP addresses you quoted imply that they are) then there is no NAT involved and those instructions are irrelevant.
I'm using wifi.
That is irrelevant too.

manleypv
Posts: 11
Joined: Thu Oct 08, 2015 11:48 am

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 7:51 pm

drgeoff wrote:
manleypv wrote:
drgeoff wrote:If you have the RPi and PC on the same LAN (and the IP addresses you quoted imply that they are) then there is no NAT involved and those instructions are irrelevant.
I'm using wifi.
That is irrelevant too.
Sooo...what is?

JimmyN
Posts: 1109
Joined: Wed Mar 18, 2015 7:05 pm
Location: Virginia, USA

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 8:35 pm

Joe Schmoe wrote:
I ran

Code: Select all

sudo apt-get install ntfs-3g
and it was already installed anyway.
That's not surprising. But the fact remains that you don't need it for Samba to work. I was just advising the poster who claimed otherwise.
I suppose you're talking about my post. I never said anything about Samba, why would you install Samba to access a shared folder on a Windows system? I was incorrect about the ntfs, you'd use cifs, don't know where my mind went on that one.

I share a folder on my Win7 PC and I mount it on the RPi using

Code: Select all

sudo mount -t cifs -o username=<username>,password=<password> "//192.168.0.3/Downloads" /mnt/win7
No Samba needed. And anything I download on the PC is available on the RPi.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 8:51 pm

No Samba needed. And anything I download on the PC is available on the RPi.
That *IS* Samba. Where do you think the "smb" in "smbmount" (or whatever they are calling it these days) comes from?

Yes, I know you don't call smbmount (or whatever they are calling it these days) directly, but it just invoked for you "under the hood".

Both the client and server parts of it are referred to, collectively, as Samba.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: FTP from Pi to PC without internet?

Wed Oct 21, 2015 9:13 pm

manleypv wrote:I have a script running on the Pi 2 that takes an image, opens ftpserver and puts image on PC, deletes image from Pi, and the cycle repeats at a determined interval.
There are many ways to do this, but, I suppose, there are fewer ways if a Windows machine is involved. At least fewer ways that are fun. I would, this is just me, set up the server on the RPi and copy from it to the Windows box, could be ftp but you could easily just use ssh or a tiny web server.

I'd get the camera to save the file to the /tmp directory so that it wouldn't be hitting the flash drive. I'd just loop doing that over and over again. I would experiment with pauses in the loop, say sleep for 1s, because if you are going to download the files from somewhere else asynchronously, if you just run it full speed, it might spend a lot of time deleting/writing the files and your attempts to read the files might not work since the window of availability would be tiny. In my testing with this simple system, I was getting much better throughput waiting 1s in the write loop and 1s in the read loop than just letting it run free. If you want to implement some sort of queue and buffer, a lock or something, maybe message passing, I don't know, maybe dust off the Erlang, have fun!

Return to “Troubleshooting”