Sign in to follow this  
Followers 0
Pradeep Reddy

FTP Problem

2 posts in this topic

Hi

I wrote a script to get a file from many servers. however its not running and i cant seem to figure out why

#include <Date.au3>
#include<File.au3>
#include<FTP.au3>

$Filename=StringFormat("NMSAlarms.%s-%s-%s",@YEAR,@MON,@MDAY)


for $i=1 to _FileCountLines("C:\Alarms.txt")
    $InputLine=FileReadLine("C:\Alarms.txt",$i)
    $array=StringSplit($Inputline,",")
    $NodeType=$array[1]
    $NodeName=$array[2]
    $IP=$array[3]
    $InputDir=$array[4]
    $OutputDir=$array[5]
    $InputFilename=StringFormat("%s%s",$InputDir,$Filename)
    
    Select 
    case $NodeType="SMP"
        $UserName="root"
        $Password="xxx"
        
    case $NodeType="IVR"
        $UserName="root"
        $Password="yyy"
        
    case else 
        $UserName="root"
        $Password="zzz"
    EndSelect

    $Open = _FTPOpen('MyFTP Control')
    
    $Conn = _FTPConnect($Open, $IP, $UserName, $Password)
    
    
    $FtpG = _FTPGetFile($Conn,$InputFilename,$OutputDir)
    
    $Ftpc = _FTPClose($Open)
    
Next

When i execute the script, then it runs without any errors but doesnt get the files. The files indeed exist on the servers but somehow they r not getting transferred. When i tried to debug then the @error value returned after _FTPGetFile is -1. the rest are 0.

Pls help :whistle:

Oh btw the Alarms.txt file is as shown below

SMP,n3smpa1,10.132.121.51,/u06/NMSclient/logs/,C:\AlarmsLog\n3smp\

SMP,n3smpa2,10.132.121.52,/u06/NMSclient/logs/,C:\AlarmsLog\n3smp\

Thanks and Regards

Pradeep

Share this post


Link to post
Share on other sites



Hi

I wrote a script to get a file from many servers. however its not running and i cant seem to figure out why

Using FTP transfers in a production environment mandates a production quality ftp client; with robust error checking. Many have written wrappers around such clients in order to be able to obtain valuable error checking methodologies.

Your problems could be many and varied.

You can:

1) grok the udfs you are currently using to determine the source of the -1 return code.

2) attempt to determine why the -1 code exists and how many different things could cause it.

3) extend the udf to reduce the number of things that can cause that error code; providing additional / better error information, _OR_

write a wrapper around a robust ftp client , such that you can leverage the benefit of someone else's years of programming and debugging, rather than having to invent the wheel natively in au3. Of course, if someone has the time and experience to write such a beast, I'd love to see it, but writing a robust ftp client is not a trivial exercise. The wide variety of operating systems and commonly used hacks to deal w/ various popular implementations and their extensions, along with the WIIIIDE range of ftp servers and their various levels of protocol compliance and protocol feature support out there alone make it a big job.

I would recommend you examine the ncftp utils available from www.ncftp.org. In particular, a ncftpget wrapper would be just the thing for your needs.


Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0