- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- comparing 2 string variables in a script
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-25-2010 11:28 AM
тАО08-25-2010 11:28 AM
#!/bin/ksh
testid=$(id $1)
echo $testid
prodid=$(remsh epicprod -n "id $1")
echo $prodid
if [[ $prodid = $testid ]]
then
echo "uid's are the same on both systems"
fi
There must be something wrong with my '$prodid = $testid' expression because even though the earlier echoes show identical character strings, the expression does not see them as equivalent.
What am I missing?
Solved! Go to Solution.
- Tags:
- compare
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2010 11:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2010 11:46 AM
тАО08-25-2010 11:46 AM
Re: comparing 2 string variables in a script
And here's a simple test to show you the reason:
# X="a b c";Y="a b c";[ $X = $Y ] && echo same || echo differ
ksh: b: 0403-012 A test command parameter is not valid.
differ
# X="a b c";Y="a b c";[ "$X" = "$Y" ] && echo same || echo differ
You need to compare one string to one string, not multiple ones.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2010 02:02 PM
тАО08-25-2010 02:02 PM
Re: comparing 2 string variables in a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2010 10:05 PM
тАО08-25-2010 10:05 PM
Re: comparing 2 string variables in a script
Note: This is NOT comparing strings, this is doing pattern matching.
It might be better to use the tried and true:
if [ "$prodid" = "$testid" ]