- 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 01:34 PM
тАО04-01-2009 01:34 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:44 PM
тАО04-01-2009 01:44 PM
Re: output | read B; echo $B ( now it works now it doesn't )
> last two lines output null.
Then I would suspect that your 'sed' may have eliminated everything but whitespace.
Notice that:
# sed -e '/^$/d'
...doesn't delete lines consisting of spaces. You probably want:
# sed -e '/^[ \t]*$/d'
...where the '\t' is a TAB character and there is a blank (space) before that.
Too, it is cheaper to do:
# sed -e 'sed '...' -e sed -e '...'
...than to run a pipe of sed-to-sed.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 05:57 AM
тАО04-02-2009 05:57 AM
Re: output | read B; echo $B ( now it works now it doesn't )
However, nope that is not it. I tried your alternate sed expression and still same problem with the new sed code for blank lines. I put a wc -c on the end of the expression and got "6". I put a wc -l on the end of the expression and got "1". The expression outputs the correct numeric 5-digit value on each run, on one line only.
I talked to another sysadmin and he said this is due to fact that this is linux running on the HP box and that the so-called "ksh" on linux is not a "true" ksh shell and so this is not working the same as it would on HP-UX.
How to do? So I still cannot take the output of the pipes and save it to a variable. Any suggestions of alternate method to get the output of the expression stored into a variable that can be used later in the script?
Regards!
gil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 06:07 AM
тАО04-02-2009 06:07 AM
Re: output | read B; echo $B ( now it works now it doesn't )
I should add that some variations of 'sed' do _not_ understand '\t'. THus, instead of writing:
# sed -e '/^[ \t]*$/d'
...to delete blank lines, do:
# sed -e '/^[ ]*$/d'
...where the bracketed characters are a space and a TAB character as typed on your keyboard. Since I despise trying to read this later, I use Perl:
# ... | perl -pe 's/^\s*$//'
...which says substitute any _whitespace_ present (spaces, tabs, newlines) with nothing if the whitespace occupies the whole line.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 06:11 AM
тАО04-02-2009 06:11 AM
Solutionfunction GetMaxSeq
{
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'
}
maxseq=$(GetMaxSeq)
echo ${maxseq}
HTH
Duncan
I am an HPE Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 06:16 AM
тАО04-02-2009 06:16 AM
Re: output | read B; echo $B ( now it works now it doesn't )
Look it's not the sed or perl issue. If I run this:
echo "A" | read B
echo $B
the "echo $B" is unset null blank.
it's an issue with piping to "read" on linux - not a sed / perl issue. I guess "read" cannot be used in this way on the flavor of ksh that linux supports.
so what I am needing is some sort of alternate way to send output of a command, or a bunch of piped commands, etc. to a variable.
Is there some way other than "read" to do that?
Thanks for your help, Gil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 06:21 AM
тАО04-02-2009 06:21 AM
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-02-2009 06:24 AM
тАО04-02-2009 06:24 AM
Re: output | read B; echo $B ( now it works now it doesn't )
This is what I said originally and what Duncan has reinfourced:
# echo "A" | while read B; do echo ${B};done
A
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 06:34 AM
тАО04-02-2009 06:34 AM
Re: output | read B; echo $B ( now it works now it doesn't )
> echo "A" |while read B; do echo ${B};done
A
> echo $B
>
Duncan's:
> function gimme
> {
> echo "A"
> }
> maxseq=$(gimme)
> echo ${maxseq}
A
Not same. :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 06:36 AM
тАО04-02-2009 06:36 AM
Re: output | read B; echo $B ( now it works now it doesn't )
On my server:
> echo "A" |while read B; do echo ${B};done
A
> echo $B
>
Duncan's:
> function gimme
> {
> echo "A"
> }
> B=$(gimme)
> echo ${B}
A
Not same. :-) What I need and have now is a way to get the piped output stored in a variable. Thanks All. Mission accomplished.
- « Previous
-
- 1
- 2
- Next »