If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > How to automate FTP from Unix to Windows machine?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-13-04, 11:17
tanboonhoe tanboonhoe is offline
Registered User
 
Join Date: Feb 2004
Posts: 16
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.
Reply With Quote
  #2 (permalink)  
Old 02-18-04, 08:43
S_Scheible S_Scheible is offline
Registered User
 
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.
Reply With Quote
  #3 (permalink)  
Old 02-18-04, 11:04
tanboonhoe tanboonhoe is offline
Registered User
 
Join Date: Feb 2004
Posts: 16
Thanks, it helps me a lot...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On