There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
UNIX/Linux
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > UNIX/Linux >
Automate FTP Upload


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Gibble's Avatar
Distinguished Member with 27,137 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
25-Jun-2002, 02:54 PM #1
Automate FTP Upload
I need to write a script that can ftp files to my webserver automatically.

Please help.

Basically all I need to know is how I can script FTP Uploads, I don't need the script written I just don't know where to start for that one piece.
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
26-Jun-2002, 09:51 AM #2
You could use several methods, including:

(1) re-directing ftp commands from a file or a here document (e.g., ftp < ftpcommands.in). Note that you could also execute the commands directly from a shell script that controls the ftp session.
(2) using tkl/expect
(3) using perl

Hope this helps.
__________________
The slowest component still sits at the keyboard.
Gibble's Avatar
Distinguished Member with 27,137 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
26-Jun-2002, 11:35 AM #3
I like that first idea...do you have an example?
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
27-Jun-2002, 12:07 PM #4
Here's a QND snippet that may be useful. The basic idea is that the script is passed an expression that evaluates to a list of files to transfer (*.htm, for example). All files are placed in the same location on the remote system. Of course, you could make this a lot smarter and put files in different locations or transfer to different systems, etc. Note that the script requires a .netrc file in your home directory to automate the login process for ftp.

ftp mysite.com << EOF
cd somedirectory/location/on/remote
prompt
binary
mput "$*"
bye
EOF

Hope this helps.
__________________
The slowest component still sits at the keyboard.
Gibble's Avatar
Distinguished Member with 27,137 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
09-Jul-2002, 02:30 PM #5
Yep it appears this will work
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
11-Jul-2002, 03:44 AM #6
Hey, Gibble --

Thanks for the reply. Glad it worked out (not the most elegant solution, but at least a starting point). Glad I could post something you found useful.

-codejockey
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:44 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.