The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
SFTP files to two servers vharsha Shell Programming and Scripting 3 05-10-2009 11:23 AM
sync files from two different servers. madan1 Shell Programming and Scripting 2 03-10-2009 12:50 PM
what files need to copy when clone servers? arm_naja SUN Solaris 3 02-04-2008 03:52 AM
Search Files In Unix Servers varsai123 UNIX for Dummies Questions & Answers 2 08-21-2007 03:27 AM
moving files across multiple servers kymberm UNIX for Advanced & Expert Users 2 10-23-2002 12:04 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 2 Weeks Ago
sexyTrojan sexyTrojan is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 6
Unhappy copy files to different servers

Please Help!
I have data containing wav, txt and different type of files on server A and i'm trying to write a script to copy these files in server B, C and D but each type of files goes to different directories on those server for eg. txt files goes to Text directory and wav goes to music directory and so on. But before copying over I wish to back up the files if the file in server A already existed in server B,C and D
The servers are mirror to each other. I tried to get started but then then i got stuck when trying to copy multiple files resulted from ls

Code:

#!/bin/sh

#### I am now in server A ######
echo "what directory where your store your files?"
read dir
varA=`ls $dir`
array=(serverB serverC serverD)
for index in array
do
ssh array[index]
echo "$PWD"
for file in $varA; do
case $file in
*.wav)
cd /root/music/Mymusic/ | cp $varA $varA$.bak

##stuck##
  #2 (permalink)  
Old 2 Weeks Ago
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,568
Not sure to get you here (still half asleep?...)
in your loop
the fact that you ssh to a server in such a way I believe will not work (its opening a new shell ...)

Why not use expect?
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0