LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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, 03: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, 03:32 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,774
Blog Entries: 1

Rep: Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339
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 03:35 PM.
 
Old 03-23-2011, 03: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, 03:59 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,774
Blog Entries: 1

Rep: Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339
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, 04: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:09 PM
ftp password on my script: is it insecure? xri Linux - Networking 5 12-10-2006 06:58 PM
get password through shell script shashwat.gupta Programming 6 06-14-2006 02:42 AM
How to tell shell script a password? Etoile Linux - Newbie 5 04-05-2006 10:16 PM
Shell Script For Password cpope67 Programming 4 01-10-2005 03:16 AM


All times are GMT -5. The time now is 04:57 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration