LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do I read and write to text files on a remote computer's hard drive

I would like to read and write data to a text file on a remote computer. This is easily accomplished using one of the file functions such as "write characters to file.vi". If I am already connected to the remote computer, all I need to do is specify the path to the particular file and it will work fine.

My problem is that I want to connect to the remote computer programatically within LabVIEW (I do not want to have to use the computer's OS to establish the connection. Is there a function that I can use to do this?
Thomas D. Schaefer
Wells Manufacturing Corp
0 Kudos
Message 1 of 6
(3,578 Views)
Thomas,

If you don't want to use native OS functionality (why not?), you'll need to have some sort of installed program active on the remote machine that can act as a server process to receive file I/O requests and make the desired changes on the filesystem.

So, the question becomes: what sort of program will be installed on the remote machine? If you had LabVIEW on the remote system, or if you have the ability to build LabVIEW executables, then you could use VI Server functionality to essentially remote-control LabVIEW and its file I/O functions by responding to requests using TCP/IP. A non-LabVIEW option would be an FTP server.

By far, the easiest option is to mount the remote filesystem locally and use LabVIEW's file I/O functions normally, as you have noted. Why again is that not a good solution for you? Maybe if the problem has more to do with mapping/mounting the remote filesystem, the forum can provide some advice.

Regards,
John
0 Kudos
Message 2 of 6
(3,564 Views)
John,

I have about ten automated test systems (there is no human interaction) that collect and log certain types of test data. I find it advantageous to store all of this data on a central hard drive. It is easier to access for report generation and backup. I would prefer to not have an application not running on the target machine as it is not managed by me. If the owner of this server decides to restart this machine, it could possibly break any connection that I may have established through the native OS. Some of my test stations are mac based, some are windows based. On the mac machines, I have establised the connection and created an alias of the target hard drive. I can then use the apple events to open this alias (establishing the connection). I suppose that I can create something similar on the windows based machines. I just thought that there would be a cleaner solution to this for both platforms. My current solution does not allow me to programatically disconnect from the target machine. This would be useful if the target machine has a limit to the number of users at a given time.
Thomas D. Schaefer
Wells Manufacturing Corp
0 Kudos
Message 3 of 6
(3,561 Views)
Instead of writing directly to the server, an approach that works for me is to store files locally and have a separate program that periodically sees if the server is up and running and then transfers the file. Once the transfer is succesful, the local files are deleted. This ensures that no data is lost and the actual test programs do not stop because of an error condition.
0 Kudos
Message 4 of 6
(3,557 Views)
Hi Johnner,
Since you are becoming a "western wall" for labView for me, maybe you can help me out on this one again.
I am doing FTP datarate measurements through the command windows,logging in to the ftp server use , ,
and or . I am reading the datarate and time that the downlaod (or upload)session took in and old fashon way (cut&paste). I found several examples aslike the one that I am attaching now, but I cannot modify it to read me the string that I need i.e. :"19xxx bytes received in 8.86Seconds 8316.09Kbytes/sec"
Can anyone help?

Example of my session.
ftp> bin
200 Type set to I.
ftp> prompt
Interactive mode Off .
ftp> mget *
200 Type set to I.
200 PORT command successful.
150 Opening BINARY mode data connection for Half.zip(73663934 bytes).
226 Transfer complete.
ftp: 73663934 bytes received in 8.86Seconds 8316.09Kbytes/sec.

Thanks in advance
Yariv
0 Kudos
Message 5 of 6
(3,524 Views)
Yariv,

You should really start a new thread with a new question like this, so that more people see it. Some people look primarily at threads that have no responses yet. Also, don't post the exact same question in multiple places. Or, if you must cross-post to some other forum, make sure to mention it in your question text.

I'm happy to be a brick in your Western Wall, but I'm not sure what the main objective is here. Is the main problem really getting access to the "X bytes received in Y seconds at Z bytes/sec" string? Or is it accomplishing the file transfer? And what OS and LabVIEW version are you running?

I think your problem is that you the LabVIEW System Exec command does not allow for the degree of interactivity that you need if you want to issue a sequence of commands to a command-line executable. However, under Windows XP (and, presumably, other Windows versions, though I can't check), you can tell the FTP executable to use commands from a textfile script by using the -s switch, and you can override the prompts during multiple file transfers with the -i switch:

ftp -i -s:FILEPATH SERVERNAME

If you issue a command in this format to System Exec, and make sure to create a file at FILEPATH with your command sequence (one per line), then you should at least accomplish the FTP actions. This won't give you the transfer details in the standard output, unfortunately. However, if you just want a general sense of how much was transferred and how quickly it happened, you can code that in LabVIEW by getting the resulting file sizes and using Tick Count before and after the System Exec call to see how long the transfer took.

Hope that helps,
John
0 Kudos
Message 6 of 6
(3,501 Views)