Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ksh: Problem with array elements containing spaces

Status
Not open for further replies.

TSch

Technical User
Jul 12, 2001
557
DE
Hello everyone,

I need to create an array containing the description text of several SAP transport. Problem is, that these description texts contain spaces (blank characters).

Here's my problem code:

Code:
set -A Text $(for items in `cat /scripts/global/tmp/Requests.lst`; do x=$(ssh machine "su - dbuser -c \"echo \\"select CHAR\\\(T2.AS4TEXT, 100\\\) from sapsystem.E070 T1, sapsystem.E07T T2 where T1.TRKORR=T2.TRKORR and T1.TRKORR=\\\'\\\\$items\\\'\\" | database +p -x\"");echo "$x"; done)

=> For every Request ID within /scripts/global/tmp/Requests.lst he is supposed to read the Description Text from the Database and add it to the Array "Text".

So if the Description Text would be something like "This is the request for shopping system" the array would contain 7 elements instead of only 1 as intended ...

Could you help me out ?

Regards,
Thomas
 
Hi

Try this way instead :
Code:
[b]set[/b] -A Text

[b]while[/b] read items; [b]do[/b]
  x=$(ssh machine [green][i]"su - dbuser -c \"echo \\"select CHAR\\\(T2.AS4TEXT, 100\\\) from sapsystem.E070 T1, sapsystem.E07T T2 where T1.TRKORR=T2.TRKORR and T1.TRKORR=\\\'\\\\$items\\\'\\" | database +p -x\""[/i][/green])
  Test[${#Test[@]}]=[green][i]"$x"[/i][/green]
[b]done <[/b] /scripts/global/tmp/Requests.lst


Feherke.
feherke.ga
 
Did you try just changing the IFS (Internal field separators) to something else (like "tab")?
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Here is an example:
Code:
==> cat m1
IFS='
'
set -A fn $(
sqlplus -s / <<EOSQL
set pages 0 term on echo off ver off feed off
select name from v\$event_name where rownum < 11 order by 1;
exit
EOSQL
)
i=0
n=${#fn[@]}
echo "n=$n"
while [ i -le n ]
do
  echo "$i - ${fn[$i]}"
  (( i+=1 ))
done

==> m1

n=10
0 - IORM Scheduler Slave Idle Wait
1 - Parameter File I/O
2 - VKTM Init Wait for GSGA
3 - VKTM Logical Idle Wait
4 - logout restrictor
5 - null event
6 - pmon timer
7 - rdbms ipc message
8 - remote db file read
9 - remote db operation
10 -

==>
[noevil]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top