LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 01-25-2009, 10:47 AM   #1
visitnag
Member
 
Registered: Mar 2008
Posts: 147

Rep: Reputation: 15
sending a file thru ftp to multiple users at a time....


Hi,

We have 23 users(at remote area) and they are all connected. We are presently sending any file thru rcp command thru ftp, but here we are doing this job 23 times (i.e., one at a time). Is there any way to send a file to all users at time with a single command thru ftp? Here everybody is having a common ftp user id as 'bouser' and all their password is same.

we even tried thru rsync (rsync -av <file> ipaddressath but this is also same like rcp, and we have to do it 23 times and each time we have to type password.

Thank you in advance...
 
Old 01-25-2009, 10:55 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
You could make a script which reads a file with ip's and sends the file one by one
 
Old 01-26-2009, 02:57 AM   #3
visitnag
Member
 
Registered: Mar 2008
Posts: 147

Original Poster
Rep: Reputation: 15
Thank you repo,

Can you please give me a sample script..for suppose i have following ip addresses...

10.xx.yy.41
10.xx.yy.42
10.xx.yy.43

and all above are having a ftp login
user name : getin
password : searchin
file to be sent to above ipaddresses : salpatch.tar

please guide me... thank you.
 
Old 01-26-2009, 03:07 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
To put ftp commands in a script you can use a simple here document. The only dis-advantage of this kind of script is that you have to write the password in clear text inside a script. A really bad security issue if someone else gain read access to your script. Anyway, here is the way to do:
Code:
#!/bin/bash
wd=/path/to/local/dir
dir=/path/to/the/remote/dir
file=salpatch.tar
for i in {41..43}
do
  ip_address=10.xx.yy.$i
  ftp -ni $ip_address <<-EOS
  user getin searchin
        binary
        lcd $wd
        cd $dir
        put $file
        bye
        EOS
done
 
Old 01-26-2009, 07:46 AM   #5
visitnag
Member
 
Registered: Mar 2008
Posts: 147

Original Poster
Rep: Reputation: 15
Thank you,

If ipaddresses are not serial...how to change...the script..

10.xx.3.131
10.xx.32.3
10.xx.31.32

10.xx is common...

what is <<-EOS?

Last edited by visitnag; 01-26-2009 at 07:48 AM.
 
Old 01-26-2009, 08:28 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
If you cannot compute an arithmetic formula to list all the IP addresses, just list them all in the for statement:
Code:
for ip_address in 10.xx.3.131 10.xx.32.3 10.xx.31.32
do
  ftp -ni $ip_address <<-EOS
  user getin searchin
        binary
        lcd $wd
        cd $dir
        put $file
        bye
        EOS
done
If you have them stored in a file (e.g. iplist) just pass the output of cat to the for statement:
Code:
for ip_address in $(cat iplist)
do
Quote:
Originally Posted by visitnag View Post
what is <<-EOS?
Take a look at the section of the Advanced Bash Scripting Guide I linked in my previous post and it will be clear. The EOS is a custom string (you can chose any string at your pleasure). The input to the file (that is the here document) will terminate as soon as the string is encountered (see the matching EOS at the end of the ftp commands). Regarding the hyphen, here is an excerpt from the aforementioned guide:
Quote:
The - option to mark a here document limit string (<<-LimitString) suppresses leading tabs (but not spaces) in the output. This may be useful in making a script more readable.
 
Old 02-05-2009, 10:45 AM   #7
visitnag
Member
 
Registered: Mar 2008
Posts: 147

Original Poster
Rep: Reputation: 15
Thank you all....


1. In out of 23 client servers few are having different ftp passwords but they have same user name 'getin' (as against i told earlier)....how to send the same file to them...

2. we are using rhel4as..we are getting 'KERBROSE' error when we try to login thru ftp (but is logging in) what is this KERBROSE?
 
Old 02-05-2009, 10:57 AM   #8
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
1. Well, you have to store the password somewhere in a file and read them using the same method for IP addresses. Maybe store the IP address in a file together with the username and password. Suppose you have a file
Code:
10.xx.3.131 getin lookfor
10.xx.32.3 getin lookat
10.xx.31.32 getin searchin
following my previous example, instead of using a for loop you can use a while read construct like this:
Code:
while read ip_address user password
do
  ftp -ni $ip_address <<-EOS
  user $user $password
        binary
        lcd $wd
        cd $dir
        put $file
        bye
        EOS
done < ip_list
2. KERBEROS is a computer network authentication protocol. Look at info here and here.
 
  


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
FTP Folder accessible by multiple users question JohnnyAvocado Linux - Networking 1 01-13-2007 07:39 AM
kde 3.4 and Multiple Users... Using sound at the same time nicolaslara Linux - Software 4 10-03-2005 01:55 AM
Sending a file to a web server via ftp mrobertson Programming 11 07-06-2005 09:12 AM
One shared folder for multiple ftp users -- vsftpd rover Linux - Networking 0 06-17-2004 06:07 AM
need multiple users to have read/write access to a Quickbooks file at the same time. rbelknap Linux - Security 2 10-14-2003 10:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

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