Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    16

    Unanswered: How to automate FTP from Unix to Windows machine?

    I need to automate (auto login) a FTP process from an unix server to a Windows machine. I need to check for the transfer status as well so that I can send a failure message to a designated unix user whenever they log on later? I would appreciate if you can show me some sample codes? Thanks.

  2. #2
    Join Date
    Feb 2004
    Posts
    17
    You could try something like this:
    Code:
    #!/bin/bash
    # <<EOF allows for passing lots of commands
    ftp ftp.sample.com <<EOF
    username
    password
    lcd localdir
    cd remotedir
    put localfile
    bye
    EOF
    
    # $? reads the exit code of the last program
    if ! [ "$?" = "0" ]
      then mail -s subject designated_unix_user <<EOF
    Hi there, seems like the backup went wrong at $( date ).
    Greets,
    
    the backup daemon
    EOF
    fi
    It is not perfect, I didn't test it as a whole. I especially couldn't pass the password this way for some reason, but I guess there are other ways to pass the credentials (f.i. with a ftp://username:password@host URL, check man ftp) if this doesn't work at your place either. Just play around a bit.

  3. #3
    Join Date
    Feb 2004
    Posts
    16
    Thanks, it helps me a lot...

Posting Permissions

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