此內容不適用於您所偏好的語言。

此內容已顯示為其他適用語言。 您的瀏覽器可能含有可協助翻譯的套件。

Copy a File Programmatically with FTP from my PC to my Linux Target

Updated Oct 23, 2020

Environment

Hardware

  • cRIO-9039
  • cRIO-9049

Software

  • LabVIEW

Operating System

  • NI Linux Real-Time

I have a cRIO 9039 and I want to use FTP programmatically. Which function do I have to use and how can I do it ?

It is possible to FTP files programmatically with your device. On this example, I use a cRIO 9049 but it also works with cRIOs that have a Linux RT OS. There are two ways to do it programmatically: you can use the function FTP Get File.vi or you can use the function FTP Put File.vi:
 
  • Get a file with FTP programmatically:
Your cRIO will be the client so you need a FTP server on your computer. The one I used on this example is Filezilla Server but it will work with others servers you can find on internet. You must launch this FTP server on the PC where the file you want to transfer is saved. These are the steps you must follow :
 
1. First, open Filezilla server and go on File and Connect to server.... Configure and start the FTP server with the default parameters:
 
 
2. Then, go on Edit and Users. In General, create the name of the user. Under Users, click on Add and write the name of the FTP server you want (we will re-use this name later). The name I chose is Server:
 
 
3. In Shared folders, you select the folder that you want to share on the FTP server. First you click on Add and then you select the right folder. In this case, the server is Downloads:
 
 
4. Now you server is launched so you can open your LabVIEW project. Under you target, you have to create a VI and you can use this code. The login is the name we choose for the server, the host is the IP address o fthe FTP server (my Windows computer), th file to copy is the name of the file the client will select on the folder of the server and the local path is the path on the Linux target where you want to copy the file (it's important to add the name of the file):

5. Now your FTP server is ready, you just have to deploy the VI on the target. The program will copy the file test.txt in the directory /home/lvuser on the Linux target:
 
 
  • Put a file with FTP programmatically:
1. First, you must ensure the Legacy FTP Server is installed on your cRIO. If not, please see Using FTP With an NI Linux Real-Time Target. Once the software is on the cRIO, you can create a LabVIEW project and use the function FTP Put File.vi as shown on the picture:
 

2. Once the VI is executed, your file test.txt is copied in the directory /home/lvuser on the Linux target. The result will be similar as the first solution with the function FTP Get File.vi.