Find the answer to your Linux question:
Results 1 to 4 of 4
Good Morning, I am developing a script for automaticli transfer using FTP, but the script is not working. Here is the script itself: /usr/sbin# bash -xv ftp.sh #!/bin/bash ftp -in ...
  1. #1
    Just Joined!
    Join Date
    Sep 2009
    Location
    Belo Horizonte, Minas Gerais - Brasil
    Posts
    6

    Unworking FTP transfer script.



    Good Morning,

    I am developing a script for automaticli transfer using FTP, but the script is not working. Here is the script itself:

    /usr/sbin# bash -xv ftp.sh
    #!/bin/bash
    ftp -in <<EOF
    open <SERVER_IP>
    user <USER> <PASS>
    cd backup
    mget *
    mdelete *
    bye
    EOF
    + ftp -in
    /usr/sbin#

    What can i change in to make it work?

  2. #2
    Just Joined!
    Join Date
    Sep 2009
    Location
    Belo Horizonte, Minas Gerais - Brasil
    Posts
    6
    Well, studyng a little harder, i've found out tha i was suposed to create a idependentend file with the ftp commands to feed the script. I've createda file named EOF, but i still have errors.

    Contento of the "eof" file:

    /usr/sbin# cat EOF
    open <ip>
    user <user> <pass>
    cd backup
    mget *
    mdelete *
    bye

    Content of the ftp.sh file:

    #!/bin/bash
    ftp -in <<EOF
    #open <ip>
    #user <usuario> <senha>
    #cd backup
    #mget *
    #mdelete *
    #bye
    #EOF

    Script exiting screen:

    :/usr/sbin# bash -xv ftp.sh
    #!/bin/bash
    ftp -in <<EOF
    #open <ip>
    #user <usuario> <senha>
    #cd backup
    #mget *
    #mdelete *
    #bye
    #EOF
    + ftp -in
    ?Invalid command
    ?Invalid command
    ?Invalid command
    ?Invalid command
    ?Invalid command
    ?Invalid command
    ?Invalid command

    When i copy and paste the commandds in the ftp command, it works just fine.

    Anyone knows what could be happening?

  3. #3
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,679
    Google is your friend.

    There are many existing threads and tutorials on this topic.

  4. #4
    Just Joined!
    Join Date
    Sep 2009
    Location
    Belo Horizonte, Minas Gerais - Brasil
    Posts
    6

    Solved

    SOLVED!!!

    #!/bin/bash

    ftp -ivn << fim
    open <ip>
    user <user> <pass>
    cd backup
    mget *
    mdelete *
    bye
    EOF
    fim

    It was an error in the component between te chair and the keyboard. Since im wasan't beeing verbose (-v), I could't see the workig FTP. And since the script cleans the backup folder, it was rright to send nothing tom me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •