Send live data through ftp

Hi guys,
i would like to send data collected from some temperature sensors wired to arduino yun,to a remote ftp server,without writing anything to the sd card,using only a python script that gets data from arduino part of the yun and send it live to remote ftp server.
is this possible with yun?i can't find anything about that!
thank you :slight_smile:

I don't have any explicit help at the moment, other than to offer some search terms and ideas.

What you are looking to do is start an "FTP client" session. Your Yun is the client, that wants to talk to a server.

One way is to use the Bridge library's Process class to run a script on the Linux side, and it makes the client connection to the FTP server and sends the data.

Another idea is to just open a TCP connection, either in the sketch or on the Linux side. FTP is a fairly simple protocol that runs on top of a TCP socket stream. You could manually send the commands to start the transfer, then send whatever data you want.

Thank you shape :wink:
So,is it possible to send data through ftp (with yun connected wifi to a network)directly from the sketch,without going through the linux part of the yun?

As ShapeShifter said, the script (python or whatever you want) is stored in the linux side.

Then the sketch start the execution of the script using the Bridge Process class. When you run the script you can pass parameters that contains data.

YUN SD writing and ftp file to remote server:

put this script into cron run it at early morning for ftp previous day log, and delete it after successful upload ( could do it without SD).

Log sensor data with timestamp:

Give logfile meaningful name: like "01282015.log"

The File Transfer Protocol (FTP) is a standard network protocol used to transfer computer files from one host to another host over a TCP-based network, such as the Internet. FTP is built on a client-server architecture and uses separate control and data connections between the client and the server.

It is not easy to do it without save to local file first. possible append remote file?

darko1984:
So,is it possible to send data through ftp (with yun connected wifi to a network)directly from the sketch,without going through the linux part of the yun?

The network (WiFi and Ethernet) is attached to the Linux processor, so all network connections must go through Linux. But you don't necessarily have to write any code on the Linux side, if you use the various Bridge library classes. But I think this task would be easier to code on the Linux side.

sonnyyu:
FTP is built on a client-server architecture and uses separate control and data connections between the client and the server.

I forgot about the separate control and data streams. But it should still be possible, but it will be a fair amount of work. Open a socket to the server on port 21, and do the initial authentication and configuration negotiation. Then start a transfer using passive mode, and the server will respond with an address and port number. Open another socket using this address and port, and start sending data. When done, use the original port to close the transfer.

It can be done, but you will be implementing all of the client side protocol and handshaking yourself. This is not for the faint of heart: you will need to be comfortable with command-response programming and parsing of incoming data.

It's possible, but it's MUCH easier to write it to a temporary file and then use a regular FTP client command to do all of the work for you.

Thank you very much guys!i didn't want to use the sd card because i know that these cards doesn't have a long life if i will write data often on them! :grinning:

The SD card does have limited life, but nearly as limited as the internal flash memory.

I've not tried it, but can FileSystem.open() create a file on the Linux /tmp partition? That partition is in RAM, which is perfect for a scratch file like this and has no wear concerns.

If it's not directly accessible from the sketch, the data could be sent to the Linux side using Bridge.put() or a Process() call. Then a Python script could read the data, write it a file in /tmp, then send the file using FTP. All in all, a much simpler solution than rolling your own FTP client that streams directly.

In my application I am ftp-ing temperature data to a site…

I do NO storage of the data on the Yun, not even in tmp.
You can open an ftp file in append mode, so I just append the newly measured data to the file.

BTW: I do all this in Python on the Linux side, example code snippet can be found at:

Cool! 8) So it looks like the Python FTP client code wants an open file stream with the data to send, not just a filename. That DOES make it a lot easier... ignore everything I said before about trying to implement it yourself, this is MUCH better!