判断操作系统

 判断操作系统


 shell

myos=`uname -s`;
	 
	if [ $myos = "Linux" ]; then
			cat /etc/shadow 
	else
			cat /etc/master.passwd 
	fi



 perl
    unless (open(FH, "uname -s|")) {
        return -1;
    }
	my $OS = <FH>;
    close FH;
    chomp($OS);
    if ($OS =~ /freebsd/i) {
        $OS = "FREEBSD";
    } elsif ($OS =~ /linux/i) {
        $OS = "LINUX";
    }

print $^O



你可能感兴趣的:(判断操作系统)