- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Passing exit code vis SSH
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
08-02-2006 02:14 AM
08-02-2006 02:14 AM
Passing exit code vis SSH
All I want is to check the version of a software on a remote system through SSH. Thought of greping the version and then passing exit code, but it doesn't seems to be working. Any idea? or any better way of doing this. For eg.
ssh
TIA
Shahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2006 02:18 AM
08-02-2006 02:18 AM
Re: Passing exit code vis SSH
1) Try grep -i you may be failing a case sensitive issue.
2) Return codes are passed by exit
exit 1 bad
exit 0 good.
Call a script on the remote node and have it with exit code based on success or failure.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2006 02:25 AM
08-02-2006 02:25 AM
Re: Passing exit code vis SSH
I think you missed my question.
ssh
gives always "0", don't know why, it's same for remsh.
#ssh
#echo $?
This will also give always "0", because the SSH is always successful. I am looking for the exit code of "swlist | grep".
Hope I made it clear.
Regards
Shahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2006 02:42 AM
08-02-2006 02:42 AM
Re: Passing exit code vis SSH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2006 02:50 AM
08-02-2006 02:50 AM
Re: Passing exit code vis SSH
ssh server /tmp/test
test script:
#!/usr/bin/ksh
swlist | grep 1234
exit $?
then if you echo $? you should get the proper error code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2006 02:52 AM
08-02-2006 02:52 AM
Re: Passing exit code vis SSH
guess im doing too many things at once today.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2006 03:00 AM
08-02-2006 03:00 AM
Re: Passing exit code vis SSH
XX=$(ssh
echo "XX = ${XX}" # will be 0 if 1234 was matched; 1 otherwise"
an alternate approach:
ssh
echo "XX = ${XX}" # will be 0 if 1234 was matched; 1 otherwise"
Note that grep -q does its work silently and outputs nothing; we are only interested in a zero or non-zero exit status.
If you test ${?} on the local host, all you are doing is testing whether or not ssh was able to be spawned.