- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Test Condition
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-28-2007 11:16 PM
06-28-2007 11:16 PM
Normally, I believe IF $? is not equal to 0 means - success.
Correct me if i am wrong.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2007 11:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2007 11:25 PM
06-28-2007 11:25 PM
Re: Test Condition
The double bracket form is a ksh/Posix shell new feature. What you are doing there is even more wrong. You are doing pattern matching of an integer with a string. This just happens to work again.
Also "Word splitting and file name generation are not" are not done in [[]].
It also has more conditions and you can use || and && to combine conditions.
>I believe IF $? is not equal to 0 means - success.
Yes but you should use -ne instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2007 11:26 PM
06-28-2007 11:26 PM
Re: Test Condition
Oops, as Oviwan says, I got it backwards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2007 11:38 PM
06-28-2007 11:38 PM
Re: Test Condition
Also, what is the meaning of writing 2>&1 i have seen in end of some commands.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2007 11:39 PM
06-28-2007 11:39 PM
Re: Test Condition
A single-bracket expression calls the test(1) command, while a double-bracket expression uses the shell's built-in evaluation. A double-bracket expression supports wildcards and more operators than the single-bracket version. Perhaps most notably, with double brackets, "&&" and "||" may be used in place of "-a" and "-o".
On any UNIX and UNIX-like platform, an exit status (${?}) of zero indicates success. Conversely, a non-zero exit status usually indicates failure.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2007 11:44 PM
06-28-2007 11:44 PM
Re: Test Condition
for example
$ cd /nirvana
su: /nirvana: not found.
$ cd /nirvana >/dev/null
su: /nirvana: not found.
$ cd /nirvana >/dev/null 2>&1
...no error msg
2>&1 redirect the error msg (stderr) to /dev/null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2007 11:51 PM
06-28-2007 11:51 PM
Re: Test Condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2007 11:52 AM
06-29-2007 11:52 AM
Re: Test Condition
This is incorrect. This is also a shell built in. Using tusc shows no execs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2007 12:22 PM
06-29-2007 12:22 PM
Re: Test Condition
This is described in ksh(1) or sh-posix(1). It basically executes the system call dup2(2) in the shell: dup2(1,2)
Or: X>&Y -> dup2(Y, X)
It closes stderr and duplicates the properties of stdout to stderr.
In Oviwan's example, stdout is /dev/null so stderr is now that too.