Aix .ksh for loop script.

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Aix .ksh for loop script.
# 1  
Old 09-27-2011
Aix .ksh for loop script.


I'm trying to write a for loop to run through a list of servers and for each server copy a file to a backup file. But I can't seem to get it to run through my server list. It work for individual servers, please see below.

webservers="server1 server2"
for ws in ${webservers}
ssh ${SSH_USERID}@${webservers} "cp -p ${target_dir}${target_file} ${target_dir}${target_file}.pre.${release}"

When i run the script i get the below error
ksh: server2: not found.
ksh: server2: not found.

Any help would be much appreicated. or a point in the right direction.


# 2  
Old 09-27-2011
ssh ${SSH_USERID}@${webservers} "cp -p ${target_dir}${target_file} ${target_dir}${target_file}.pre.${release}"

with this:
ssh ${SSH_USERID}@${ws} "cp -p ${target_dir}${target_file} ${target_dir}${target_file}.pre.${release}"

This User Gave Thanks to Chubler_XL For This Post:
# 3  
Old 09-27-2011
Many thanks, thats done the business!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with loop in ksh script

Hi, I am new to UNIX. I am working on a script where it takes the input and produces a desired output and it works fine for one instance. Input(One Instance): CREATE TABLE TAB1 ( COL1, COL2 ); CREATE UNIQUE INDEX XPKTAB1 ( COL1 )TAB1; Output: CREATE TABLE TAB1 ( COL1, COL2... (8 Replies)
Discussion started by: varun2327
8 Replies

2. Shell Programming and Scripting

ksh while read loop breaks after one record - AIX

#!/bin/ksh for SRV in imawasp01 \ imawasp02 \ imawasp03 \ imawasp04 \ imawasp05 \ imawasp06 \ imawasp07 \ imawasp08 \ imawasp09 do print "${SRV}" while read PASSLINE do SRVNAME=`echo ${PASSLINE} | awk -F\: '{print $1}'` LASTLOGIN=`ssh ${SRV} lsuser ${SRVNAME} | tr '... (2 Replies)
Discussion started by: port43
2 Replies

3. Shell Programming and Scripting

[Solved] AIX ksh script -d <- what does it mean?

I'm looking at a line in a script: && DRROOT="/dir1" || DRROOT="/dir2" I'm trying to understand it. Is there a "-d" command and is it seeing if /dir1 exists and, if so, set an environment variable named DRROOT to "/dir1", else set DRROOT to "/dir2" ? Thanks, -dog ---------- Post... (0 Replies)
Discussion started by: landog
0 Replies

4. Shell Programming and Scripting

AIX-ksh script ends unexpectedly

Hi, I have a ksh script running on AIX 5.3 which has sometimes a bizarre behaviour. The script runs a child script like follow. trap 'rm -f /tmp/res.log;exit 0' 2 15 > /tmp/res.log 2>&1 echo " is terminated" next instructions... rm -f /tmp/res.log ... (12 Replies)
Discussion started by: rivalgro
12 Replies

5. Shell Programming and Scripting

explain while loop in ksh shell script

#!/bin/ksh log=ABCl log=EFG log=HIJ i=0 while <------ what is the meaning of ($i - lt 3) do print ${log} (( i=i+1 )) done (1 Reply)
Discussion started by: Bperl1967
1 Replies

6. Shell Programming and Scripting

Setting a variable in a while loop (.ksh script)

Hello Everyone, I'm still trying to grasp many concepts in .ksh scripting, one of them being variables inside loops. My problem is the following: * I'm trying to set a variable inside a while read loop to reuse it outside of said loop. My lines are the following :... (13 Replies)
Discussion started by: jimmy75_13
13 Replies

7. Shell Programming and Scripting

AIX .ksh script freezes when using the mail -s command

Hello I am trying to send an email when a .KSH script is run on an AIX Machine. This email will only include a subject line that is made up of variables from within the script, and is as follows: CURRENT_DATE=`date +%Y%m%d` TIME=`date` ADMIN="" date block () { ... (4 Replies)
Discussion started by: jimbojames
4 Replies

8. Shell Programming and Scripting

for loop in awk script using ksh

Guys, I am new in awk , I face problem while i try to use for loop in awk, I am using ksh, i am trying to set a for loop which runs as man times as the records in a file , the for loop like for(a=1;a<=5;a++) is working in my awk script but the one i need is not working :wall: for example ... (8 Replies)
Discussion started by: djahmed
8 Replies

9. Shell Programming and Scripting

KSH Script -- loop and data copy question

I am trying to write a script that will allow me to train others with commands that I run manually by only allowing the exact command before continuing onto the next set of commands. Here is where I come into an issue. I have changed the directories for this post. Software we run creates files... (2 Replies)
Discussion started by: hurtzdonut
2 Replies

10. Shell Programming and Scripting

ksh script to analyze log files on AIX 5.2

Hi, I have written a script that traps errors on different servers from the log files based on the current system date. The trapped errors are written to a file and file is sent as an attachment to an email. I would like to run this script for every 2hrs. when i run the script from the second... (0 Replies)
Discussion started by: itzcoolbuddy
0 Replies
Login or Register to Ask a Question