The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
I need help with arrays in C Shell domain Shell Programming and Scripting 5 11-19-2008 08:17 AM
how to use arrays in c shell hgphsf Shell Programming and Scripting 6 12-14-2007 02:03 PM
Bourne Shell and Arrays Unbeliever Shell Programming and Scripting 2 07-25-2005 10:48 AM
Shell arrays in oracle stored procedure superprogrammer Shell Programming and Scripting 6 06-09-2005 06:36 PM
Can there be multi-dimensional variable arrays in borne shell? jparker Shell Programming and Scripting 4 05-15-2002 04:47 PM

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

Join Date: Nov 2006
Posts: 234
arrays in shell script

Hi,

can we use arrays in shell script?

I have this so far:
#!/bin/sh
isql -Usa -P -S DBSERVER -o output << EOF
sp_transactions "state", "prepared", "xactname"
go
/
EOF

the file 'output'' will be have many entries and I want to caputre the transaction names only: grep 000 output works fine.

how to put these names into an array?

TRAN_NAME_LIST=$(grep 000 output) does not work.

thanks.
  #2 (permalink)  
Old 05-17-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Melanie,
Do you have to put the data into an array?
Would this work for you:
Code:
mSQL="sp_transactions "state", "prepared", "xactname";"
mSQL=$mSQL"go;"
echo $mSQL | isql -Usa -P -S DBSERVER -o output 2>>mLogFile
Then you can do a grep to the output file.
If this doesn't work, give us the format of your output and what
your expected results.
  #3 (permalink)  
Old 05-18-2007
melanie_pfefer melanie_pfefer is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 234
thanks but this gives the same result: A file with this format:

xactname



-------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
----------------
000007D6_dj0TcjcQnPgOc30PdPAPe5YTdjgRdjdvd34Ve38VdPsTnQ5ll4ZvnRZv00000000000000
0000000000000000_dPkQdjkPnPgNejwOejsTe5ZvnRY000000000000000000000000000
00000000000000000000000000000000

000007D6_dj0TcjcQnPgOc30PdPAPe5YVdj8NcPhvd34Ve38VdPwOnQ5ll4ZvnRZv00000000000000
0000000000000000_ejkOcjcQnPgNejwOejsUcRZvnRY000000000000000000000000000
00000000000000000000000000000000


these are 2 rows and I want to use them in this command:

dbcc complete_xact("$TRAN_NAME","rollback")

the TRAN_NAME is each of the values grepped in the file. To put these grepped values, I need an array or a list.
  #4 (permalink)  
Old 05-18-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Melanie,
After the file has been written, you can read it and execute the
"complete_xact" procedure:
Code:
mSQL="sp_transactions "state", "prepared", "xactname";"
mSQL=$mSQL"go;"
echo $mSQL | isql -Usa -P -S DBSERVER -o output 2>>mLogFile
while read TRAN_NAME
do
  dbcc complete_xact("$TRAN_NAME","rollback")
done < the_previous_output_file_name
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 06:54 PM.


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