![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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. |
|
||||
|
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. |
|
|||||
|
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
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|