Please Correct this Array Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Please Correct this Array Script
# 1  
Old 07-07-2006
Please Correct this Array Script

Here is the script. I am not able to increment and Print echo "2=" ${arr[2]}
(Bold line)
Can someone please help me correct it? I am thinking there is some escape sequence error. Just started learning scripts ...

Thanks


#!/bin/ksh

set -A arr a1 a2 a3 a4

# START

Server1=gmi

Username=test

let j=2

echo "above ssh=" ${arr[j]}

ssh -xq $Server1 -l $Username /usr/bin/ksh <<-EOS

let j=0

out=\${arr[j]}

echo "0out="\$out

for loop in ${arr[*]}

do

let j=j+1

echo "d=" \$j

echo "1=" \$loop

echo "2=" ${arr[2]}

done

EOS

# END

Last edited by psreddy1234; 07-10-2006 at 10:54 AM..
# 2  
Old 07-07-2006
i use bash these days. maybe this example will help it will print like:
hope that helps.

Anzahl= 6
1 2
2 3
3 4
4 5
5 6
6 7



#!/bin/bash

liste=( 1 2 3 4 5 6)


echo "Anzahl=" ${#liste[*]}

for ((i=0;i<${#liste[*]} ; i++ ))
do
echo -n ${liste[ $i ]} " "
echo $(( ++liste[ $i ] ))
done
# 3  
Old 07-07-2006
Where have I seen this before?
# 4  
Old 07-07-2006
Grumpf - Thanks for the help. Let me try it. Not sure if I need to to print it the same way as you suggested. I still think there is a simple escape sequence which i am missing. Anways I will try you example.

Shock - Was that question to me? If it was for me I am sure you would have not see it earlier .. coz Its just a part of the script in my present environment.

Thanks guys
# 5  
Old 07-07-2006
Looks an awful lot like this:
https://www.unix.com/shell-programming-and-scripting/28944-looping-array-inside-inside-ssh-not-working-pls-help.html

Homework assignment, impatient poster, or two people working on the same problem?
# 6  
Old 07-07-2006
Hmmm... Looks like 2 people working on the same problem .. My collogue passed it on to me .... Now i see where he got the problem from Smilie

Thanks anyways!!
# 7  
Old 07-07-2006
You'll also see that I gave an answer in the other thread - for some reason he didn't seem to like it, but I think it should work once he defines the array on the remote system (as opposed to locally). That is, unless he has some other requirement that has not been made clear.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can some one correct this script

Hi, I tried writing a script and there was a problem with SFTP part can some one correct where is is the mistake Enveronment file #!/bin/bash export HOST_NAME=<> export USER_NAME=<> export PASSWORD=<> export SOURCE_PATH=/u03/informatica/current/server/infa_shared/TgtFiles/mfg export... (4 Replies)
Discussion started by: spradeep86
4 Replies

2. Shell Programming and Scripting

Need output of script on screen and file with correct return status of the called script.

Hi, I am trying to capture logs of the script in the file as well as on the screen. I have used exec and tee command for this. While using exec command I am getting the correct output in the file but, script output is not getting displayed on the screen as it get executed. Below is my sample... (14 Replies)
Discussion started by: Prathmesh
14 Replies

3. Shell Programming and Scripting

Shell script to correct the data

Hi, I have below data in my flat file.I would like to remove the quotes and comma necessary from the data.Below is the details I would like to have in my output. Could anybody help me providing the Unix shell script for this. Input : ABC,ABC,10/15/2012,"47,936,164.567 ","1,036,997.453... (2 Replies)
Discussion started by: sonu_pal
2 Replies

4. Shell Programming and Scripting

Please Correct My script

############### #filename.sh ############### CUREENT_DATE=02 log_file_path="$CUREENT_DATE"-"${0##%*/}`|cut -d "." -f1|awk -F "/" '{print $NF}'`"".log" echo $log_file_path ################ #output required 02-filename.log (6 Replies)
Discussion started by: mohitmehral
6 Replies

5. Shell Programming and Scripting

Can anyone correct the error in this script

ret=`sqlplus -s /nolog << EOF connect $db_user/$db_pwd@$db_sid; SPOOL ./$DirectoryName/TableData.txt; set pagesize 0 feedback off verify off heading off echo off linesize 150 while read var_ack_party_name do select * from bus_event where ack_party_name like... (13 Replies)
Discussion started by: rkrish
13 Replies

6. Shell Programming and Scripting

Please correct the error in the following script

#!/bin/ksh db_user=$DB_USER_NAME db_pwd=$DB_PASSWORD db_sid=$TWO_TASK if ; then echo "\tUsage: MoveUsageProcessing <BC Log file Name>" exit 1 else BCLogFileName=$1 fi grep -i 'MoveUsage daemon needs to run on this account before it can be billed' $1 |awk -F\| '{for(i=0;++i<=NF;) if($i ~... (1 Reply)
Discussion started by: Rajesh Putnala
1 Replies

7. Emergency UNIX and Linux Support

Please correct my script

Please correct my script if it any exceptional, since im calling other external script with in my script. #!/bin/bash FE1=TMM DT1=/home/myHome/dated_1 REPORT=/home/otherHome/Report.sh ## Run the report for FE1 & DT1 cd /home/myHome SERV_LST=/home/myHome/srvc-lst echo "Welcome to... (5 Replies)
Discussion started by: raghunsi
5 Replies

8. Shell Programming and Scripting

something is not write in the script. Can some one please correct this.

Wrong post (2 Replies)
Discussion started by: tuffEnuff
2 Replies

9. Shell Programming and Scripting

Please correct my Script

I am new to awk, can somone please correct the following script awk -F "," 'BEGIN { foreach ((getline < "file1.csv") > 0) {i++ a=1 --> assuming the first column in the row will be stored in a foreach (a in f1) { if (a == $5) continue print a; } } } file2.csv' Here is what I... (11 Replies)
Discussion started by: nuthalapati
11 Replies

10. Shell Programming and Scripting

Is the script correct ???

Dear Collegues is the below given is correct ? #!/usr/bin/perl $a = @ARGV; while ($a = @ARGV) { exec "./jagan ../dat/ml_in @ARGV"; } Jagan (0 Replies)
Discussion started by: jaganadh
0 Replies
Login or Register to Ask a Question