The UNIX and Linux Forums  


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
du from list with du of list total Movomito Shell Programming and Scripting 3 05-04-2008 10:33 PM
Request to modify script to list multiple parameters for V_fieldid variable Sammy Shell Programming and Scripting 0 03-30-2008 09:08 PM
Korn pattern-list with a variable partchimp Shell Programming and Scripting 2 03-26-2008 02:12 PM
how to generate a random list from a given list mskcc Shell Programming and Scripting 3 05-30-2006 04:30 AM
Comparing a distinct value in 1 list with another list manualvin Shell Programming and Scripting 6 06-22-2004 07:42 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-14-2004
jpeery jpeery is offline
Registered User
  
 

Join Date: May 2004
Posts: 9
Using a variable list in ksh while

Hey all, been so long since I've done any KSH scriptting, I've forgotten exact sytax. 2 things,
1) I need to dot in an environment file that is a list of server names
2) I need to loop through though server names in a while loop, or until loop.
Here's roughly what I have and trying to hammer out the syntax:

# While not the end of the servers list, go through and copy
# $1 to $2
while [[ ! EOF ]]; do

scp user@server:/$1 user@server_from_list:/$2
done
exit 1

$1 would be the file I want to distribute
$2 is where I want it to go on the remote filesystem

ie.
$ ./dist .profile ~user/
This would distribute my profile to the entire list of servers in the .servers file...
I'd do it by hand, but we're talking a list of 200+ servers.

Thanks!
JP
  #2 (permalink)  
Old 05-14-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
It sounds like you want to loop through a file...
Code:
exec < inputfile
while read servername ; do
       echo name = $servername
done

  #3 (permalink)  
Old 05-14-2004
jpeery jpeery is offline
Registered User
  
 

Join Date: May 2004
Posts: 9
Thanks!

Here's what I ended up doing:

if [[ -e $1 ]]; then
cat .servers | while read LINE; do

scp $1 root@$LINE:$2
done
else
echo " "
echo "$1 does not exist"
echo " "
fi
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 03:14 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