- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ssh return code
Operating System - HP-UX
1819694
Members
3366
Online
109605
Solutions
Forums
Categories
Company
Local Language
back
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
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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-2004 06:09 PM
08-25-2004 06:09 PM
Hi Guys,
Does anyone know how to trap ssh return code? For example, on server A, ssh to server B and run command X. I would like to trap the return code of command X.
The long way to this would be to trap the return code to a file when running command X on server B, then run a scp to grab that file from server A. But what if the command itself is another ssh or scp command?
Any ideas?
Thanks in advance for your time.
Tung
Does anyone know how to trap ssh return code? For example, on server A, ssh to server B and run command X. I would like to trap the return code of command X.
The long way to this would be to trap the return code to a file when running command X on server B, then run a scp to grab that file from server A. But what if the command itself is another ssh or scp command?
Any ideas?
Thanks in advance for your time.
Tung
Solved! Go to Solution.
- Tags:
- exit status
- ssh
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2004 06:36 PM
08-25-2004 06:36 PM
Solution
The manual page of OpenSSH says:
---begin quote---
DIAGNOSTICS
ssh exits with the exit status of the remote command or with 255 if an error occurred.
---end quote---
That means, if there's an error code, if it's 255 you handle it as "an error in SSH connection". If it's anything else, you do exactly what you'd do if the remote command had been local.
If you do something like
localhost% ssh user@host1 ssh user@host2 foobar
and get an error 255, you can't tell whether the error was from a ssh connection from the local host to host1 or from host1 to host2, unless you parse the error messages somehow.
---begin quote---
DIAGNOSTICS
ssh exits with the exit status of the remote command or with 255 if an error occurred.
---end quote---
That means, if there's an error code, if it's 255 you handle it as "an error in SSH connection". If it's anything else, you do exactly what you'd do if the remote command had been local.
If you do something like
localhost% ssh user@host1 ssh user@host2 foobar
and get an error 255, you can't tell whether the error was from a ssh connection from the local host to host1 or from host1 to host2, unless you parse the error messages somehow.
MK
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP