- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- could not able to get right exit value from perl s...
Operating System - HP-UX
1753797
Members
7036
Online
108805
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
Forums
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
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
тАО02-25-2009 10:18 AM
тАО02-25-2009 10:18 AM
could not able to get right exit value from perl script
Hi,
Please check below perl & shell script.
root@ > more test.pl
#!/usr/bin/perl
print " begining of programme \n";
$val=1;
$val=system("sh check.sh");
print "Exit Value : ",$?,"\n";
print "Value of veriable val : ",$val,"\n";
root@ > more check.sh
echo "Inside Shell Script..... check.sh......";
exit 123;
unixh147-root@ /home/gm433 > perl test.pl
begining of programme
Exit Value: 31488
Value of veriable val : 31488
Why I am not able to get correct value i.e. 123 ?
How can I get value 123?
Please help me.
Thanks,
Goutam
Please check below perl & shell script.
root@ > more test.pl
#!/usr/bin/perl
print " begining of programme \n";
$val=1;
$val=system("sh check.sh");
print "Exit Value : ",$?,"\n";
print "Value of veriable val : ",$val,"\n";
root@ > more check.sh
echo "Inside Shell Script..... check.sh......";
exit 123;
unixh147-root@ /home/gm433 > perl test.pl
begining of programme
Exit Value: 31488
Value of veriable val : 31488
Why I am not able to get correct value i.e. 123 ?
How can I get value 123?
Please help me.
Thanks,
Goutam
- Tags:
- Perl
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-25-2009 11:13 AM
тАО02-25-2009 11:13 AM
Re: could not able to get right exit value from perl script
You might get better answers sooner in a
forum related to your actual OS, which does
not appear to be VMS.
forum related to your actual OS, which does
not appear to be VMS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-25-2009 12:12 PM
тАО02-25-2009 12:12 PM
Re: could not able to get right exit value from perl script
You might read the docs:
$ perldoc -f system
or
http://perldoc.perl.org/functions/system.html
where it says,
"The return value is the exit status of the program as returned by the wait call. To get the actual exit value, shift right by eight."
So, if you shift the result right by 8, you get what you are looking for:
$ perl -e "$x=system('perl -e exit(123)'); print $x"
31488
$ perl -e "$x=system('perl -e exit(123)'); print $x >> 8;"
123
If you were using Perl on VMS (which you appear not to be) you could use the vmsish 'exit' pragma to control whether you get native exit codes or POSIX emulation.
$ perldoc -f system
or
http://perldoc.perl.org/functions/system.html
where it says,
"The return value is the exit status of the program as returned by the wait call. To get the actual exit value, shift right by eight."
So, if you shift the result right by 8, you get what you are looking for:
$ perl -e "$x=system('perl -e exit(123)'); print $x"
31488
$ perl -e "$x=system('perl -e exit(123)'); print $x >> 8;"
123
If you were using Perl on VMS (which you appear not to be) you could use the vmsish 'exit' pragma to control whether you get native exit codes or POSIX emulation.
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.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP