- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: 'bc' utility in HP-UX cannot understand condit...
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
Forums
Discussions
Discussions
Discussions
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
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
06-17-2003 08:24 AM
06-17-2003 08:24 AM
set result = `echo "( $Val1 - $Val2 ) > 5.65 | bc`
According to everyone I talk to, this should work fine, but I get a syntax error. Even the man page (man bc) says that it should work.
However, if I use a program called 'bs' in place of 'bc' then everything works fine. The only problem is that 'bs' doesn't exist on any of our other systems, and most people never seem to have heard of it.
1. Why isn't 'bc' doing what the man page says it will?
2. What is 'bs' and why has nobody heard of it?
Thanks!
Daniel Gowans
Compeq International
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2003 08:46 AM
06-17-2003 08:46 AM
Re: 'bc' utility in HP-UX cannot understand conditionals?
This is probably as close an equivalent:
echo "x = 0; if ((${val1} - ${Val2}) > 5.65) x = 1; x" | bc
This will echo 1 if true 0 if false.
You can add the ` `'s.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2003 08:47 AM
06-17-2003 08:47 AM
Re: 'bc' utility in HP-UX cannot understand conditionals?
Has someone renamed BC to BS ??
Just an Idea.
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2003 08:56 AM
06-17-2003 08:56 AM
Re: 'bc' utility in HP-UX cannot understand conditionals?
I see the same result as you. I think you may need to do more "setup" in bc before you can run your statement through it, but it's been a while since I've used it.
bs is a simple programming language - more info on this can be found in its man page.
regards,
Darren.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2003 12:13 PM
06-17-2003 12:13 PM
Solutionhttp://hpux.cict.fr/hppd/hpux/Gnu/bc-1.06/
bs
http://docs.hp.com/cgi-bin/fsearch/framedisplay?top=/hpux/onlinedocs/B9106-90007/B9106-90007_top.html&con=/hpux/onlinedocs/B9106-90007/00/00/24-con.html&toc=/hpux/onlinedocs/B9106-90007/00/00/24-toc.html&searchterms=bs&queryid=20030617-141237
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 05:20 AM
06-18-2003 05:20 AM
Re: 'bc' utility in HP-UX cannot understand conditionals?
Accoding to my bc man pages, the following example is not valid as an expression:
3.0 > 9.2
According to manual pages:
Statements
E
{ S ; ... ; S }
if ( R ) S
while ( R ) S
for ( E ; R ; E ) S
null statement
break
quit
where 'E0' means EXPRESSION. But symbols >, <, >= ... don't constitute an EXPRESSION. They can be used only whithin an R ( relational operation)... and as you can see above 'R' only appears in 'if', 'while' and 'for' statements, not just alone as E.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 08:16 AM
06-18-2003 08:16 AM
Re: 'bc' utility in HP-UX cannot understand conditionals?
I understand now. It was mostly confusing me because of the man page. The previous sections saying E op E yields R made me think I could evaluate it on a single line. Go figure. Luckily there are better tools out there. I just wish it had kept up with GNU 'bc'
Daniel