LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-23-2011, 02:26 PM   #1
MarcosPauloBR
Member
 
Registered: Feb 2011
Location: Santa Catarina - Brazil
Distribution: Slackware
Posts: 129

Rep: Reputation: 3
Shell script - FTP without name and password


Hi people!

I need to make a shell script to make a ftp connection. But it will be used in cron.

How can I set a static username and password on the script??

I've tryed to find this on Google, but without sucess.

Thanks for your time!
 
Old 03-23-2011, 02:32 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Using a script:

Code:
#!/bin/bash
cd /home/username
HOST='192.168.1.1'
USER='username'
PASS='password'

ftp -n -v $HOST << EOT
user $USER $PASS
prompt
put filename.txt
get someother.txt
cd somedirectory
get somefile.txt
bye
EOT
You can change anything between prompt and bye to fit your needs.

Last edited by szboardstretcher; 03-23-2011 at 02:35 PM.
 
Old 03-23-2011, 02:47 PM   #3
MarcosPauloBR
Member
 
Registered: Feb 2011
Location: Santa Catarina - Brazil
Distribution: Slackware
Posts: 129

Original Poster
Rep: Reputation: 3
LOL

What is EOT?

I knew EOF =P

Thanks !!!
 
Old 03-23-2011, 02:59 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
EOT is end of tape
EOF is end of file

I gripped that from an older script lying around. At least it wasn't formatted for the Commodore 64 or something.
 
Old 03-23-2011, 03:01 PM   #5
MarcosPauloBR
Member
 
Registered: Feb 2011
Location: Santa Catarina - Brazil
Distribution: Slackware
Posts: 129

Original Poster
Rep: Reputation: 3
=D

So, thank you very much!

This works for me!!
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell or perl script to change ftp user password vivek rai Linux - Newbie 4 03-15-2009 01:09 PM
ftp password on my script: is it insecure? xri Linux - Networking 5 12-10-2006 05:58 PM
get password through shell script shashwat.gupta Programming 6 06-14-2006 01:42 AM
How to tell shell script a password? Etoile Linux - Newbie 5 04-05-2006 09:16 PM
Shell Script For Password cpope67 Programming 4 01-10-2005 02:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:42 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