Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Linux and Unix
Tag Cloud
access acer asus bios bsod computer crash driver drivers error ethernet excel freeze gaming gpu hard drive hardware hdmi internet laptop mac malware memory monitor motherboard music network printer problem ram registry router server slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
Automate FTP Upload

Reply  
Thread Tools
Gibble's Avatar
Distinguished Member with 27,127 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
25-Jun-2002, 03: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, 10: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,127 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
26-Jun-2002, 12:35 PM #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, 01: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,127 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
09-Jul-2002, 03: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, 04: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

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
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 05:22 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.