LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ftp within a telnet session to get files

Hello there,
 
I am trying to ftp within a telnet session to get some files off a remote server. I have a telnet address which requires only a username and no password and, within that telnet session, I ftp to another server but this one requires both a username and password. I then get the files from this server I ftp'd to and then put them on the first server. I logout/quit and then from teh first server again, I ftp to another server to put my files there. Something like this:
 
telnet to a server that needs only username and no password
from there, use ftp to open a session to a second server to get some files within a specific dir
get the files suing 'get' command and put on first server
quit or exit from second server after getting files
back onto first server that requires no password and from here again, use ftp to open a session to another server
Open the sessiont o third sever and put my files in a specific dir
quit from theird server
quit from first server
 
I can manually carry out the above but i was wondering if I could use the labVIEW internet VI's to achieve this. I started off but didnt seem to get anywhere. I have attached a file that shows what I am trying to do. I did lok around to see if anyone else was trying to do what I was trying to do but couldn't find anything. I was thinking about maybe using the telnet play script VI but I am not sure of how to use it to send commands/interact with a telnet session. Any help will be greatly appreciated.
 
Bupe.
 
if you are wondering why i have to telnet to the first server instead of ftp'ing directly to the 2nd server to get the files I need, the reason is because I can't ftp directly to the second server unless I come through the first server, no access rights directly. Security issue I guess.
0 Kudos
Message 1 of 4
(3,291 Views)
 Hello Bupe,

I viewed your document, and what you're trying to do is not possible, because the telnet session will not provide a tunnel to the second server.

You will have to handle the ftp session without the ftp VI's. The ftp commands have to be passed to server 1 via the telnet session.

1. Open telnet session, you get the telnet prompt;
2. Send ftp command via telnet session, you will reciev a message with the ftp prompt;
3. Do your ftp actions via the telnet session;
4. Close the ftp session via the telnet session;
5. Close the telnet session.

I hope this helps,

andre.buurman@carya
Regards,
André (CLA, CLED)
0 Kudos
Message 2 of 4
(3,287 Views)

Thanks Andre, I did manage to do what I wanted after all. But I realised one thing however, because some of the files I will be transfering take about 5mins and some may take as long as 10-20min, there comes about an issue with the timeout value for the 'read from telnet session' vi after I write a command to the session. If I set the timeout value to lets say 300ms, that will be almost ok for the smaller files I will be transfering but if I am transfering larger files which take about 20mins, then the session times out after 300ms before the transfer completes. If I set the timeout to 25000ms which is the default, then for the smaller files, the transfer completes and the session just hangs about. Is there a way I can determin when the transfer is complete or is there a reasonable timeout value I can use to accomodate for both the transfer of small and larger files?

 

Another issue with the read from telnet session vi is that I read in a while loop which runs every 50th of a second, currently I set the while to exit after it reaches 200. Is this reasonable? Do I need to use a while loop to read and if so does it matter a lot the length of time I read from the session. For example if I sent a command to list all the files in a given dir, how many times would I have to read to make sure I capture the entire output? If I used a while loop, when would I exit, after how long? Can this be determined or would I just have to read for a lengthy period of time hoping that I do capture the entire output?

 

cheers,

Bupe

 

Message Edited by Bupe on 06-22-2006 04:30 AM

0 Kudos
Message 3 of 4
(3,273 Views)
Hello Bupe,

It is common practise, for me it is, to read with a timeout value of about 50-100 ms in a while loop concatenating the read output in 1 string until I catch a certain expression that indicates that the command is finished. I think in case of FTP it should give a prompt at the end of a command.

The while loop does not need a timer, because the read function will wait for the timeout period when nothing is received thus releaving the processor and when it does receive something you want to process it immediately to check whether  you can stop reading.

The prevent the while loop from hanging you app,  add another condition  that allows you to stop the loop regardless.

Regards,

andre.buurman@carya
Regards,
André (CLA, CLED)
0 Kudos
Message 4 of 4
(3,259 Views)