HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- perl, ssh, status of remote command
Operating System - Linux
1828227
Members
2804
Online
109975
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
Forums
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
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
10-19-2005 05:48 AM
10-19-2005 05:48 AM
I'm writing a perl program, using the system function to call ssh to run a program on another system. I'm trying to get the exit status back from the remote command. It seems to work, except that the values are weird. An exit status of 0 comes back as a 0, but an exit status of 1 comes back as 256, an exit status of 2 comes back as 512, an exit status of 10 comes back as 2560.
The perl program is running on a firewall which is a BSD derivative, and the remote system is HP-UX 11i. They have somewhat different versions of ssh. The firewall version is a bit old.
Is the problem wih the status values likely due to the ssh versions ?, or am I doing something wrong in my perl program ?
The relevant part of my test program is like this:
$status = system("/usr/contrib/bin/ssh user\@host /whatever/myscript");
print "t1.pl status is: $status\n";
Thanks.
- John
The perl program is running on a firewall which is a BSD derivative, and the remote system is HP-UX 11i. They have somewhat different versions of ssh. The firewall version is a bit old.
Is the problem wih the status values likely due to the ssh versions ?, or am I doing something wrong in my perl program ?
The relevant part of my test program is like this:
$status = system("/usr/contrib/bin/ssh user\@host /whatever/myscript");
print "t1.pl status is: $status\n";
Thanks.
- John
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2005 06:09 AM
10-19-2005 06:09 AM
Solution
John,
I think perl's exit status processing has some sinister detail that I could not quite figure out myself but here it is from my perl bookshelf cd, the function detail page for "system" function, which has an example that may help you. HTH...
(attached as txt to preserve code formatting)
I think perl's exit status processing has some sinister detail that I could not quite figure out myself but here it is from my perl bookshelf cd, the function detail page for "system" function, which has an example that may help you. HTH...
(attached as txt to preserve code formatting)
________________________________
UNIX because I majored in cryptology...
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2005 07:57 AM
10-19-2005 07:57 AM
Re: perl, ssh, status of remote command
Thanks Mel. That's good enough for me.
That page from the manual says in part, "The return value is the exit status of the program as returned by the wait(2) call. To get the actual exit value, divide by 256. (The lower 8 bits are set if the process died from a signal.) See exec."
... and the somewhat more complete explanaion comes from, where else?, the Programming Perl book, which I'd read (but forgotten about) some time ago, and which says in part, " the lower byte has something else in it... the lowest 7 bits indicate the signal number that killed the process ( if any), and the 8th bit indicates whether the process dumped core".
- John
That page from the manual says in part, "The return value is the exit status of the program as returned by the wait(2) call. To get the actual exit value, divide by 256. (The lower 8 bits are set if the process died from a signal.) See exec."
... and the somewhat more complete explanaion comes from, where else?, the Programming Perl book, which I'd read (but forgotten about) some time ago, and which says in part, " the lower byte has something else in it... the lowest 7 bits indicate the signal number that killed the process ( if any), and the 8th bit indicates whether the process dumped core".
- John
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
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP