INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

ksh: Problem with array elements containing spaces

ksh: Problem with array elements containing spaces

(OP)
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

RE: ksh: Problem with array elements containing spaces

Hi

Try this way instead :

CODE --> Ksh

set -A Text

while read items; 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\"")
  Test[${#Test[@]}]="$x"
done < /scripts/global/tmp/Requests.lst 

Feherke.
feherke.ga

RE: ksh: Problem with array elements containing spaces

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

RE: ksh: Problem with array elements containing spaces

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close