Our Sponsors



Download BioinformaticsOnline(BOL) Apps in your chrome browser.




Question: Question: How to find Operating System name using perl script?

Neel
4125 days ago

Question: How to find Operating System name using perl script?

Hi All,
Recently I started working on severs/clusters for my biological analysis. I am struggling to find the operating system(OS) detail information before running my scripts. Can you please tell me how to find OS name using perl script?

Best Answer
3

Well if you would like to print just the name of OS then Perl is built with a $^O variable that indicates the operating system.

#!/usr/bin/perl
print "$^O";

Moreover, If you are interested in more detail then try Config module:

#!/usr/bin/perl
use Config;
print "$Config{osname}\n"; #operating system name
print "$Config{archname}\n"; #architecture name

Other Answers
1

You can also OS information by the name $OSNAME if you use the English module:

#!/usr/bin/perl
use English qw' -no_match_vars ';
print "$OSNAME\n";

 

0

You can also try Perl::OSType module for this kind of problems.

use Perl::OSType ':all';
$current_type = os_type();