- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script Works On Solaris, but not on HP-UX. Why...
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
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
тАО08-16-2001 04:16 PM
тАО08-16-2001 04:16 PM
Script Works On Solaris, but not on HP-UX. Why?
I have a strange problem. I have a script that works fine when I use it on Solaris, but fails to work on HP-UX. The script checks to see the version of an application, by querying a table called "MASTER_DB_VERSION". The table has one column that holds the current version of a table. If the version is old or not in sequence with the current patch version, then the script aborts. In other words, if I am trying to run a patch script called 1.5.0.0 then the current version of the app. had better be "1.4.x.x.". If it is anything else (i.e. 1.1, 1.2 1.3) then the script should abort. For some reason my script never runs, but always aborts because it can't evaluate the current version from MASTER_DB_VERSION. My code follows:
sqlplus ECC/ECC @versionTest.sql
currentVersion=`2.7`
verTest=`cat LOGS/versionTest.LST|grep Version|awk {'print $2'}`
if [ "$verTest" = "2.7" ];
then
/* DO THE INSTALL */
else
/* DO NOT DO THE INSTALL AND WARN USER SCRIPT ABORTED */
fi
The version test should find 2.7.0.1, and proceed with the install, but it fails . As I said before, this scripts works for Solaris, but not HP. Can someone please help.
Thanks,
Daniel N.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-16-2001 04:24 PM
тАО08-16-2001 04:24 PM
Re: Script Works On Solaris, but not on HP-UX. Why?
or "2.7" while setting currentversion
like
currentversion="2.7"
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-16-2001 11:23 PM
тАО08-16-2001 11:23 PM
Re: Script Works On Solaris, but not on HP-UX. Why?
I am an HPE Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2001 04:50 AM
тАО08-17-2001 04:50 AM
Re: Script Works On Solaris, but not on HP-UX. Why?
With regard to Duncan's comments, the behavior of the Bourne and Posix shells is different when testing two strings. Consider:
#!/usr/old/bin/sh
verTest="2.7.0.1"
if [ "$verTest" -eq "2.7" ]
then
echo ok
else
echo not_ok
fi
#.end
This is the Bourne shell (/usr/old/bin/sh) and will echo "ok".
If you use the Posix shell (/usr/bin/sh) the test will be false, returning "not_ok".
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2001 06:13 AM
тАО08-17-2001 06:13 AM
Re: Script Works On Solaris, but not on HP-UX. Why?
I would question why it actually works on Solaris!
The following test:
if [ "$verTest" = "2.7" ]
does a string comparison between "2.7.0.1" and "2.7". This should always fail.
You could try matching the strings, something like:-
currentVersion="2.7"
verTest=...
if [[ ${verTest} = ${currentVersion}* ]];
then...
Note that this will only work if the strings are NOT quoted. It is matching your extracted version (2.7.0.1) with 2.7
Jim, your example is actually doing a numeric comparison not string (-eq rather than =). It looks as though the old bourne shell evaluates each argument as an integer stopping at a non-numeric character. Thus 2.7 equates to 2.7.0.1. because both arguments are converted to the integer 2 first. The POSIX shell is much more precise than this.
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2001 06:33 AM
тАО08-17-2001 06:33 AM
Re: Script Works On Solaris, but not on HP-UX. Why?
Oops. Yes, I agree. My first thought when I read this post was that the string comparison was perhaps evaluated for the shorter operand's length. While obviously not the case, when I found that the algebraic comparsion was different for Bourne vs. Posix, I posted that but referred to "string comparison"
Well, I bungled! Thanks for the correction. Glad to see you here -- it's been too long.
With warm regards, Jim.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2001 06:43 AM
тАО08-17-2001 06:43 AM
Re: Script Works On Solaris, but not on HP-UX. Why?
I don't think this puppy really works on Solaris. I suspect that the version string really is "2.7" on that platform (or 2.7 0.1)
so that awk's $2 picks up "2.7". Solaris's shell isn't bad enough for this to work.
Clay