+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: BASH: FTP Put Script

  1. #1
    Jordan Guest

    BASH: FTP Put Script

    I created this simple script to FTP data to another server:

    Code:
    #!/bin/sh -vx
    
    # Script to FTP data to server
    # Paramters:    host            FTP Server
    #                     user            FTP Username
    #                     passwd      FTP Password
    #                     file             File to send/put
    ############################################################################
    
    # Variables
    HOST=$1
    USER=$2
    PASSWD=$3
    FILE=$4
    TONAME=$5
    
    # Connect to FTP HOST and Send File
    ftp -n $HOST <<END_SCRIPT
        quote USER $USER
        quote PASS $PASSWD
        dir
        ascii
        put $FILE $TONAME
       dir
       quit
    END_SCRIPT
    exit 0
    Usage:
    Code:
    # ./ftpscript <host> <username> <passwd> <filename> <toname>
    Example:
    Code:
    # ./ftpscript 127.0.0.1 jordan SomePass /var/log/messages /upload/messages.txt

  2. CODECALL Circuit advertisement

     
  3. #2
    Hektor is offline Programmer
    Join Date
    Jan 2007
    Posts
    126
    Rep Power
    0
    Interesting. Is there no wput (opposite of wget) command?

  4. #3
    Jordan Guest
    Yes, there is but it doesn't come "stock" on any Linux distro that I know of. Home of wput

  5. #4
    Join Date
    Aug 2006
    Posts
    11,209
    Blog Entries
    6
    Rep Power
    101
    What do you mean with "stock", you mean out-of-the-box?

  6. #5
    Tor
    Tor is offline Programming Expert
    Join Date
    Oct 2007
    Posts
    488
    Rep Power
    0
    Yes I believe that is what he meant. "stock" is a term often used in English/America that means exactly like you stated: out-of-the-box with no enhancements.

  7. #6
    kiddies is offline Programmer
    Join Date
    May 2009
    Posts
    129
    Rep Power
    0

    Re: BASH: FTP Put Script

    how a syntax to make password n username with list...like this

    ./ftpscript <host> <username.txt> <passwd.txt> <filename> <toname>

  8. #7
    Jordan Guest

    Re: BASH: FTP Put Script

    You'll need to change the script to read the files. You can use the 'cat' command for this.

  9. #8
    kiddies is offline Programmer
    Join Date
    May 2009
    Posts
    129
    Rep Power
    0

    Re: BASH: FTP Put Script

    ohhh, use the cat for call a file text in to bash...
    right or not...

  10. #9
    ikonia is offline Newbie
    Join Date
    May 2009
    Posts
    24
    Rep Power
    0

    Re: BASH: FTP Put Script

    if you want to use sftp you can use ssh keys which removes the need for username / password.

  11. #10
    Jordan Guest

    Re: BASH: FTP Put Script

    You can use cat to read the contents of a file and add those contents to a variable.

+ Reply to Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Multi-Exec - A helpful free bash script to execute scripts on multiple servers
    By phpforfun in forum Linux Programming and Scripting
    Replies: 0
    Last Post: 10-13-2011, 12:12 AM
  2. [HELP] convert Perl script to Bash shell script
    By Egypte in forum Linux Programming and Scripting
    Replies: 2
    Last Post: 04-24-2011, 05:37 PM
  3. Pidgin Password Recovery Bash Script
    By kresh7 in forum Bash / Shell Scripting
    Replies: 3
    Last Post: 09-18-2009, 04:25 PM
  4. BASH: SSHFS Backup Script
    By Jordan in forum Bash / Shell Scripting
    Replies: 2
    Last Post: 06-21-2009, 08:00 AM
  5. What is bash?
    By LemonMan in forum Linux/Unix General
    Replies: 3
    Last Post: 01-26-2009, 08:24 AM

Tags for this Thread

Bookmarks

Posting Permissions

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