LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-21-2012, 04:43 PM   #1
Ashish Sood
Member
 
Registered: Feb 2009
Location: Gwalior
Distribution: Fedora 22, RHEL 6,7
Posts: 180

Rep: Reputation: 15
Automate Shell Script For FTP


Hi,

I am new to shell scripting, I just want to make my work automate by making a single shell scripting program for downloading the data from ftp server to my local system.

I googled and find some scripting for this task. but none of them is working fine on my Fedora 14 system.

Guys please give me some idea about this how could i make my task automate.

Thanks ,
Ashish Sood
 
Old 01-21-2012, 05:08 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,662

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by Ashish Sood View Post
Hi,
I am new to shell scripting, I just want to make my work automate by making a single shell scripting program for downloading the data from ftp server to my local system. I googled and find some scripting for this task. but none of them is working fine on my Fedora 14 system. Guys please give me some idea about this how could i make my task automate.
So you're an RHCE, and can't write a simple shell script?? And you say you Googled, but don't bother telling us what you used/tried, what error(s) you get, or what problems you're having, so how can we help??

Since you're an RHCE, you should have at least heard about the expect command, and using it to automate such things...and since you've Googled, you've probably found one of the MANY examples on using expect to perform FTP tasks.
 
Old 01-21-2012, 05:19 PM   #3
Ashish Sood
Member
 
Registered: Feb 2009
Location: Gwalior
Distribution: Fedora 22, RHEL 6,7
Posts: 180

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by TB0ne View Post
So you're an RHCE, and can't write a simple shell script?? And you say you Googled, but don't bother telling us what you used/tried, what error(s) you get, or what problems you're having, so how can we help??

Since you're an RHCE, you should have at least heard about the expect command, and using it to automate such things...and since you've Googled, you've probably found one of the MANY examples on using expect to perform FTP tasks.

TBone => Yes i tried to make a script but its stucks after taking the username and its not move to next line for the password.

To be a certified some time its happen we cant make the simple thing,instead we do a thing which is not simple as its look.
 
Old 01-21-2012, 05:28 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,662

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by Ashish Sood View Post
TBone => Yes i tried to make a script but its stucks after taking the username and its not move to next line for the password.
Ok...so then how about posting your script? We can't guess as to why it's "stucks".
Quote:
To be a certified some time its happen we cant make the simple thing,instead we do a thing which is not simple as its look.
..except this, which is very simple. And since you looked at Google, did you see ANY OF THE THOUSANDS OF EXAMPLES??? Like these first two hits?

http://www.stratigery.com/scripting.ftp.html
http://www.linuxjournal.com/article/3065

Did you bother looking on here, since this very question has been asked (and ANSWERED) many times?
 
Old 01-21-2012, 07:50 PM   #5
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi Ashish Sood,

I totally agree with TBone that you did not search on google nor did you read ftp manpage because if you would have then you have got the answer by now.

Anyways, in the beginning of your script put the following line:

Code:
#!/bin/bash
ftp ftp://username:password@servername
This will make your user to login without the need of entering password. Remember the password will be plain text. I have not tried hashing it but you could.

Last edited by T3RM1NVT0R; 01-21-2012 at 07:52 PM.
 
1 members found this post helpful.
Old 01-22-2012, 08:41 AM   #6
rodrifra
Member
 
Registered: Mar 2007
Location: Spain
Distribution: Debian
Posts: 202

Rep: Reputation: 36
I agree with both TB0ne and T3RM1NVT0R.
You can also use .netrc to avoid putting passwords all over your scripts' ftp connections.
Besides, here documents will be of help automating the task.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Expect script to automate ftp upload mabin Linux - General 4 12-19-2018 06:48 AM
Is it Possible to Automate this Procees using shell script!! anishkumarv Linux - Newbie 8 05-20-2011 07:22 AM
script to automate EDI by FTP wademac Programming 4 04-14-2008 01:34 PM
shell script to automate TELNET daggulasreedhar Programming 5 08-02-2007 12:13 PM
Automate FTP session using Shell Script kalyanofb Programming 2 04-07-2007 08:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration