LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to send files using FTP

Is there any way I can implement and control FTP transfers from within my CVI application?  I just want to FTP some files to my target system.

Thanks
0 Kudos
Message 1 of 10
(4,642 Views)

That depends on which version of CVI you have and whether or not you have the Internet Library. It used to be a separate add-on to CVI back when I first used it but it is definitely included with the full development system since at least version 7.0, maybe earlier.

There are functions to do an automatic transfer in one function call and to do it at a lower level.

Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 2 of 10
(4,642 Views)

Even with older versions of the IDE you can always use Windows API functions to implement a FTP transfer. Look at InternetConnect and FTPOpen functions in the SDK.

Finally, I'm not sure but it seems to me that you can also use DataSocket technology too for such a transfer.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 10
(4,627 Views)

There are always all sorts of options if you don't have the Internet Library. One of my favorite things to do is to use small Perl scripts for things I know it can do well such as regular expression parsing, I simply call the script with system() and pass the parameters to it on the command line. Since there is a very easy to use FTP module for Perl and Perl is open-source and free, this could be a viable option instead of diving into the mess that is the SDK and dealing with low-level protocol details.

Remember, the first virtue of the programmer is laziness. Reuse code whenever possible, use the tools that do the job with the minimum of effort, and don't re-invent the wheel.

Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 4 of 10
(4,606 Views)
Thank you all for your replies.. I have the LabWin CVI 8.0 and it does have the internet library.. I am currently working on it to to write the FTP calls that I want to make.. It was yesterday giving me problem with opening a connection with the FTP server.. I was just giving the IP of the unit under test (which the command syntax says to provide)... I would probably need to provide the complete url including the FTP server itself...
0 Kudos
Message 5 of 10
(4,599 Views)

Actually, an IP address should work. When you give a URL, it eventually is resolved through DNS to an IP address.

The schema part of the URL denotes the protocol, which is FTP and that is what you are trying to use anyway.

Now where this can get a bit messed up is if the server is configured to use a nonstandard port for serving the FTP protocol. This would be the caes if the domain portion of the URL has a : (colon) followed by a number such as ftp://ftp.somedomain.com:12345/ That denotes that a nonstandard port of 12345 is in use to serve that protocol.

Using the domain name has the advantage of looking up the IP address for you and you don't have to worry about tracking IP addresses should the server address change. It has the disadvantage of requiring DNS and DNS can sometimes cause delays of several seconds in connecting if the load at the DNS name server is high.

Using the IP address will be quicker, though under normal circumstances only marginally so. It has the disadvantage of requiring you to track any IP address changes of the server.

Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 6 of 10
(4,596 Views)
I am actually using the IP address of the unit..but I always get the message "Not authorized to access the FTP server with given user name and password".. however if I try the same thing using command prompt I am able to make the FTP connection successfully using the same user name and password.. I have also tried using different ports..
0 Kudos
Message 7 of 10
(4,593 Views)

It is possible that the FTP server you are attempting to connect to is a non-standard server. It wouldn't happen to be running VxWorks would it?

A typical Unix-style login looks like this:

% ftp server.somedomain.com
Connected to server.somedomain.com.
220 (vsFTPd 2.0.3)
User (server.somedomain.com:(none)): martin
331 Please specify the password.
Password:
230 Login successful.
ftp>

I no longer have access to any VxWorks based servers but I think the FTP server in VxWorks uses prompts that the CVI FTP functions don't recognize. This is particularly true of the directory output that it returns. When you log in via a terminal window, what do the prompts look like?

Since VxWorks is such a common target environment, it would be nice if CVI's FTP library could handle its quirks. It would also be nice if the developers of VxWorks would fix their non-standard implementation so it worked with 3rd-party libraries that expect Unix-style FTP output and prompts.

Unfortunately, even if VxWorks is fixed, it doesn't help all those legacy systems out there.

I doubt that handles returned from the Telnet functions will work with the FTP functions, if they did, you could telnet into the FTP port and log in and then go do the rest of what you need to do with the FTP functions.

If they don't, you can still do it all via the telnet interface (I think) but then you would have to essentially write your own FTP client library. That would be a major pain for anything but trivial operations.

If I were faced with this situation, I would turn to the Perl solution I described above, it is what I know and I can make it it work quite easily.

 

Message Edited by MJF on 07-11-2006 11:16 AM

Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 8 of 10
(4,593 Views)
In case your ftp server requires a particular username and passowrd, you may find useful this link


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 9 of 10
(4,580 Views)

The Internet Library FTP functions take a username and password, that is not the issue. What is at issue is whether the FTP function is able to parse the responses it is getting from the server or not and whether it is able to respond with the proper information at the proper time to achieve a log in.

While the scheme outlined in the link Roberto posted may work in a browser, I am not so sure it will with the FTP functions in CVI. It certainly can't hurt to try it but I personally doubt it will work.

Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 10 of 10
(4,575 Views)