- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: output | read B; echo $B ( now it works now i...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2009 12:20 PM
тАО04-01-2009 12:20 PM
------
#!/bin/ksh
# Program Notes
echo "set linesize 200 heading off echo off verify off feedback off pagesize 0
select max(sequence#) from v\$log_history;
quit
" | sqlplus -s / as sysdba | sed 's/^[ \t]*//;s/[ \t]*$//' | sed '/^$/d' | read maxseq
echo $maxseq
------
My question is that i find that on some boxes the "read" command will read in the output from pipe into the variable "maxseq" but then when I put this on other boxes, it does not, in other words, sometimes "read" as used above does not work. I don't really understand what is affecting whether or not this will work.
Is there a more reliable alternative for reading the output of the sqlplus call into a variable that is reliably portable across different boxes?
Thanks, Gil
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2009 12:26 PM
тАО04-01-2009 12:26 PM
Re: output | read B; echo $B ( now it works now it doesn't )
WHere this works, you are probably running an HP-UX POSIX shell or a Korn (ksh) one. Where this fails, you are probably running the Bash shell.
With the HP-UX Posix or ksh shell, this works:
# echo a b c | read X Y Z
# echo ${X}
a
Under Bash, nothing is printed :-)
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2009 12:30 PM
тАО04-01-2009 12:30 PM
Re: output | read B; echo $B ( now it works now it doesn't )
...and I forgot to add, if it is in Bash environments that you have the problem, then this:
# echo a b c | read X Y Z
...can be rectified with this:
# echo a b c|while read X Y Z;do echo ${X};done
a
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2009 12:40 PM
тАО04-01-2009 12:40 PM
Re: output | read B; echo $B ( now it works now it doesn't )
echo "set linesize 200 heading off echo off verify off feedback off pagesize 0
select max(sequence#) from v\$log_history;
quit
" | sqlplus -s / as sysdba | sed 's/^[ \t]*//;s/[ \t]*$//' | sed '/^$/d' | while read maxseq; do echo ${maxseq}; done
echo $maxseq
echo ${maxseq}
last two lines output null. The main command does output the current value of the query = "13134" but it is not getting "stored" into "maxseq" and I can't subsequently reference it. Am I doing something incorrectly in the way I implemented your suggested code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2009 12:44 PM
тАО04-01-2009 12:44 PM
Re: output | read B; echo $B ( now it works now it doesn't )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2009 12:54 PM
тАО04-01-2009 12:54 PM
Re: output | read B; echo $B ( now it works now it doesn't )
echo "set linesize 200 heading off echo off verify off feedback off pagesize 0
select max(sequence#) from v\$log_history;
quit
" | sqlplus -s / as sysdba | sed......
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2009 12:59 PM
тАО04-01-2009 12:59 PM
Re: output | read B; echo $B ( now it works now it doesn't )
echo "set linesize 200 heading off echo off verify off feedback off pagesize 0
select max(sequence#) from v\$log_history;
quit
" | sqlplus -s / as sysdba
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2009 01:03 PM
тАО04-01-2009 01:03 PM
Re: output | read B; echo $B ( now it works now it doesn't )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2009 01:06 PM
тАО04-01-2009 01:06 PM
Re: output | read B; echo $B ( now it works now it doesn't )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2009 01:12 PM
тАО04-01-2009 01:12 PM