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 > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
recursive wc on a directory? bimba17 UNIX for Dummies Questions & Answers 13 06-21-2009 11:51 AM
Recursive FTP -- here at last. Perderabo Shell Programming and Scripting 52 03-25-2009 12:15 PM
Recursive pid script jbarnhar Shell Programming and Scripting 3 05-02-2007 03:14 PM
recursive sorting fermisoft UNIX for Advanced & Expert Users 1 08-16-2005 08:46 AM
Recursive FTP aslamg UNIX for Dummies Questions & Answers 1 03-08-2001 04:27 AM

Closed Thread
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 11-06-2003
Nicol Nicol is offline
Registered User
  
 

Join Date: Sep 2003
Location: Paris
Posts: 128
recursive rcp

I wrote a shell script (AIX) to extract the file "/rep1/toto" from all the hosts referred in a list and send them to one local directory named ~/$host-$file with the hostname as prefix

rcp -p user@host:/rep1/$file ~/$host-$file

where file = toto ==> it works !

I would do the same thing but with "/rep1/toto*" (all files beginning with toto in /rep1 ) and naming these files "$host-$file"

for example : host1-toto1 ; host1-toto2 etc...

could someone help me , please

thanks in advance

christian
  #2 (permalink)  
Old 11-06-2003
davidg's Avatar
davidg davidg is offline
Registered User
  
 

Join Date: Jul 2003
Location: Holland
Posts: 207
for i in `rsh $server "ls /rep1/"`
do
rcp /rep1/${i} mycomefromserver:/path/to-dir/${server}-${i}
done

Regs David
  #3 (permalink)  
Old 11-06-2003
Nicol Nicol is offline
Registered User
  
 

Join Date: Sep 2003
Location: Paris
Posts: 128
Thanks for your answer , but first i would test if i enter :

/rep1/toto or

/rep1/toto* , in other words if the input contains a "*"

to do or not the loop

i'm searching for the test , if you have the answer please welcome !

christian
  #4 (permalink)  
Old 11-06-2003
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
Try
Code:
case $INPUT in 
    *\*) echo input ends with a star;; 
    *) echo otherwise;; 
esac
  #5 (permalink)  
Old 11-06-2003
Nicol Nicol is offline
Registered User
  
 

Join Date: Sep 2003
Location: Paris
Posts: 128
Thanks that's right ,

last thing , for the same script i would extract the filename from a string whether the string is short or long :

/rep1/rep2/rep3/file => file

or /rep1/file => file

i'm trying with awk command and NR parameter without success at this time , maybe (for sure) you will find before me ?

thanks

christian
  #6 (permalink)  
Old 11-06-2003
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
For sure, lookup the dirname and basename commands
Code:
basename /rep1/rep2/rep3/file
  #7 (permalink)  
Old 11-06-2003
Nicol Nicol is offline
Registered User
  
 

Join Date: Sep 2003
Location: Paris
Posts: 128
in french , we say "bon dieu mais c'est bien sūr"

=> oh god for sure

sorry i'm surely tired , it was so simple !

thanks a lot

christian
Closed Thread

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 06:17 PM.


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