The UNIX and Linux Forums  


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
bat file opening multiple IE windows Pitt Windows & DOS: Issues & Discussions 2 04-04-2009 12:06 AM
Can BASH execute commands on a remote server when the commands are embedded in shell bash_in_my_head Shell Programming and Scripting 1 12-04-2008 01:51 AM
Shell script to call multiple java commands vivekdn Shell Programming and Scripting 4 09-03-2008 01:28 AM
Opening multiple documents at once Orange Stripes Shell Programming and Scripting 2 05-12-2008 12:56 PM
Opening a UNIX shell in Java guyi Shell Programming and Scripting 2 08-13-2007 06:00 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-27-2009
akar_naveen akar_naveen is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 4
Unhappy Run multiple commands in $() without opening a new shell

The code below works, but takes too many lines and looks awkward:


Code:
        db2 "export to $filename of del select * from $table with ur"|tee -a $LOGFILE|awk '/Number of rows exported:/ {print $5}' > numrows.tmp
        numrows=$(cat numrows.tmp)
        rm numrows.tmp

When I try the statement below instead, I get a message saying there's no connection to the database. That's because it opened a new shell. It's opening a new shell when I give more than just the db2 command. How can I get the code below work:


Code:
numrows=$(db2 "export to $filename of del select * from $table with ur"|tee -a $LOGFILE|awk '/Number of rows exported:/ {print $5}' )


Thanks in advance
Naveen

Last edited by Franklin52; 08-27-2009 at 04:42 PM.. Reason: Please use code tags!
  #2 (permalink)  
Old 08-27-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,334
You can read the value like this:


Code:
db2 "export to $filename of del select * from $table with ur"|tee -a $LOGFILE|awk '/Number of rows exported:/ {print $5}' | read numrows

  #3 (permalink)  
Old 08-27-2009
akar_naveen akar_naveen is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 4
numrows variable is not getting anything assigned by read.
Reply

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 02:02 AM.


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