LabWindows/CVI

取消
显示结果 
搜索替代 
您的意思是: 

Download Simple Text File from internet URL (Basic CVI)

已解决!
转到解答

I am trying to download a simple text file locally to the computer using CVI (Basic package).

 

i have seen numerous examples of Web browser and other crazy whistle programs.  All I want to do is travel to a URL and download the text file in the background.  I tried using the IWebBrowser program but could not figure out how to save the file to my specified output name without prompting the user.

 

To be even more specific, here is a sample URL.  I want to save this file as yuma.txt in my working directory.  No prompts or anything.

 

http://www.navcen.uscg.gov/archives/gps/2009/ALMANACS/YUMA/001.ALM

to be saved as yuma.txt

 

Please be specific on what instruments or dlls to use and where to get them.

 

Thanks alot!

0 项奖励
1 条消息(共 9 条)
6,758 次查看

I made up this sample application that performs reading through the web. Downloaded data are shown on screen: saving them to a file is up to you.

The program uses only windows API function to access remote file, so the only thing you will need to run it is full SDK that comes with CVI.



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?
2 条消息(共 9 条)
6,740 次查看
Sorry, but your program was unable to compile because I believe I do not have the wininet.h or other library files.  I am currently using the Basic Installation of labWindows.
0 项奖励
3 条消息(共 9 条)
6,714 次查看

You could try something along the lines of this using the telnet library:

tlsession = InetTelnetOpen("www.navcen.uscg.gov", 80, 0); 

tlstatus = InetTelnetWrite(tlsession, "GET http://www.navcen.uscg.gov/archives/gps/2009/ALMANACS/YUMA/001.ALM HTTP/1.1Host: www.navcen.uscg.gov", "\r\n", -1, &byteswritten, 25000);

tlstatus = InetTelnetRead(tlsession, tlread, 100000, &bytesread, 25000);

The complications are that upon reading you will either have to wait until the timeout, key off something on the page to know when you hit the end and use the function InetTelnetReadUntil(), or know the exact number of bytes the server is going to serve up.  There will also be some header information you'll have to strip out.  

You'll need the telnet library which is part of the internet library I do not know if it included in the more basic CVI package.

0 项奖励
4 条消息(共 9 条)
6,705 次查看

Internet is not included ... if it was, it would be much simpler!

 

Errors from the telnet example include:

 

 Undefined symbol '_InetTelnetOpen@12' referenced in "telnet.c"

 Undefined symbol '_InetTelnetRead@20' referenced in "telnet.c".
 Undefined symbol '_InetTelnetWrite@24' referenced in "telnet.c".
 Undefined symbol '_InetTelnetClose@4' referenced in "telnet.c".

 

Which by the way are really annoying when NI includes all these examples and yet half of them don't work because I have the Basic version.

0 项奖励
5 条消息(共 9 条)
6,700 次查看

I suggest you install the free cygwin package (get it at http://cygwin.com).

Then you can use the wget program as a simple solution. Plus you get a

lot of useful unix tools. It looks like there is also a version available at

http://gnuwin32.sourceforge.net/packages/wget.htm , but I haven't tried

that one.

 

#include <stdio.h> #include <utility.h> #include <ansi_c.h> int main(int argc, char *argv[]) { int ret; ret = LaunchExecutable("e:\\cygwin\\bin\\wget http://www.navcen.uscg.gov/archives/gps/2009/ALMANACS/YUMA/001.ALM"); if (ret) { fprintf(stderr, "ret is %d\n", ret); fprintf(stderr, "Press a key to exit.\n"); GetKey(); } exit(ret); }

 

I have tested the above and it seems to work.

 

---

     Marty O.

6 条消息(共 9 条)
6,668 次查看

That mini program does work, however, I am not sure how I would include and check to make sure that the end-user has that program upon installation. 

 

The workaround i see with this though, is when the user does download, once he runs the program, I can check for a certain library/wget file in the registry, and if it's not there, ask them to download.  If it is there, then I can download the file I need.

 

As i was thinking about it, another workaround is using the webbrowser program/fp and have it operate on a hidden panel, download the file automatically, then rename the file (if needed), then discard the panel.  this, however would have alot of overhead.

0 项奖励
7 条消息(共 9 条)
6,647 次查看
解答
接受人 ngay528

After installing the GnuWin wget program, I was able to extract just the wget.exe and .dll files from the bin directory and get the program to work on another computer.  So, this would be the ultimate solution. 

 

http://gnuwin32.sourceforge.net/packages/wget.htm

 

Because of this, the only losses are not having a preset file that comes with the program installed in the default path (which you can bypass any input in command line arguments anyway) and having the register of the installedpath.

 

So this solution seems to work!  Thanks

Message Edited by ngay528 on 02-19-2010 09:47 AM
0 项奖励
8 条消息(共 9 条)
6,641 次查看

RMonitor.zip was very helpful. Thanks a lot. Hats off

0 项奖励
9 条消息(共 9 条)
5,631 次查看