AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
#Operatingsystems
#Servers
 View Only
  • 1.  How to use FTP with batch file

    Posted 04/26/11 08:39 AM

    Originally posted by: mikezang


    I tried to use FTP with batch file as below:

    FTP < ftp.txt

    The content as below in file ftp.txt

    open 12.34.56.78
    userid
    passwd
    But it doesn't work, what can I do?
    #AIX-Forum


  • 2.  Re: How to use FTP with batch file

    Posted 04/26/11 08:46 AM

    Originally posted by: hdkutz


    Hello,
    this issue is described in the man-page from ftp-command. Search for .netrc File.
    http://www.letmegooglethatforyou.de/?q=AIX+ftp+.netrc

    Cheers,
    ku
    #AIX-Forum


  • 3.  Re: How to use FTP with batch file

    Posted 04/26/11 09:03 AM

    Originally posted by: mikezang


    Thanks for your reply.

    But my question is little complex.

    I telnet to a.b.c.n, then I have to go into a specific folder with today date, then do ftp and get a file, I did it as below, where do I have to modify?

    In file if.csh
    #!/usr/bin
    echo "cd /TAMA_arch/`date +%Y%m%d`_IF" > if1.csh
    echo "ftp < ftp.txt" >> if1.csh
    chmod +x if1.csh

    echo "ftp a.b.c.d" > ftp.txt
    echo "user xxx" >> ftp.txt
    echo "pw" >> ftp.txt
    echo "get Data_file_`date +%Y%m%d`.rar" >> ftp.txt
    echo "bye" >> ftp.txt

    ./if1.csh
    rm Data_file_`date +%Y%m%d`.rar
    #AIX-Forum


  • 4.  Re: How to use FTP with batch file

    Posted 04/26/11 09:11 AM

    Originally posted by: blanckea


    Hello,
    You should use ftp -n in order to script it.
    Regards
    #AIX-Forum


  • 5.  Re: How to use FTP with batch file

    Posted 04/26/11 09:49 AM

    Originally posted by: mikezang


    Thanks, I will try it tomorrow.
    #AIX-Forum


  • 6.  Re: How to use FTP with batch file

    Posted 04/29/11 01:40 AM

    Originally posted by: mikezang


    Hi,
    I hope to use script in ftp command, but it didn't use other commands in script except open command, what can I do ?

    my script as below

    open 1.2.3.4
    id
    pw
    mget file.txt
    bye
    #AIX-Forum


  • 7.  Re: How to use FTP with batch file

    Posted 04/29/11 02:43 AM

    Originally posted by: J.Y.


    1. !/bin/sh
    2. All you need is to pass an EOF:
    ftp -in 'SERVER' << EOF
    user
    USERNAME PASSWORD
    bin
    YOUR STUFF
    quit
    EOF
    #AIX-Forum


  • 8.  Re: How to use FTP with batch file

    Posted 04/29/11 02:56 AM

    Originally posted by: mikezang


    Thanks for your code, but I can't find -in option in AIX ftp manual, can you explain for me?
    #AIX-Forum


  • 9.  Re: How to use FTP with batch file

    Posted 04/29/11 02:58 AM

    Originally posted by: mikezang


    Sorry, I understand -in:(
    #AIX-Forum


  • 10.  Re: How to use FTP with batch file

    Posted 04/29/11 03:00 AM

    Originally posted by: blanckea


    Hello, I don't see any thing complex in your query, and as already told you should use ftp -n.
    So from your original script posted, it should be (I translated it to ksh I don't use csh) something like :
    In file if.ksh
    #!/usr/bin/ksh
    cd /TAMA_arch/`date +%Y%m%d`_IF
    #you can also add -v after -n if you want verbose output
    ftp -n a.b.c.d <<END
    user <user_name> <password>
    bin
    get Data_file_`date +%Y%m%d`.rar
    bye
    END

    #End of script

    Regards
    #AIX-Forum