Re: Help in checking the OS type...



*Don't top post.*

On 4/25/06, Mazhar <syedmazhar.hasan@xxxxxxxxx> wrote:
Paul,

It lists me out the operating system name thanks for the same. How can i go
about getting the different drives/volumes created on the same...

Regards
Mazhar

On 4/25/06, Paul D. Kraus <paul.kraus@xxxxxxxxx> wrote:



On 4/25/06, Mazhar <syedmazhar.hasan@xxxxxxxxx> wrote:

Hi Folks,

I need to develop a script where in i need to first check the type of OS
and
then go about in finding the drives.




pkraus@pkraus-laptop:~$ cat testperl.pl && perl testperl.pl
print "OS:$^O\n";
OS:linux
*$^O*

The name of the operating system under which this copy of Perl was built,
as determined during the configuration process. The value is identical to
$Config{'osname'}.
http://www.perl.com/doc/manual/html/pod/perlvar.html

HTH,
Paul

File systems are system-specific. How you access them and find out
information about them is an OS issue, not a perl issue. Most
operating systems provide some version of the 'df' or 'du' system
commands. Some don't. Most operating systems provide some version of
and fstab file or /proc system. Some don't. If you don't knoe how to
access filsystem information on your system, you need to find a good
reference for your system. There are mailing lists devoted to most
major OSes; there are also many good books. If you need information on
a particular OS, let us know which one, and someone here can probably
point you in the right direction.

If you script needs to be portable, you'll need to lean about the
commands and/or system calls for the differnt systems you intend to
run the script on. Then insert some simple logic to do the right thing
on a particular system, e.g.:

if ( $^O =~ /some_os/ ) {
# do something
} elsif ( $^O =~ /some_os/ ) {
# do something different
} elsif ( $^O =~ /some_other_os/ ) {
# do something completely different
}

And so on for each OS. You could also check out Sys::Filesystem. but
then you already knew about that, because you took 30 seconds to do a
simple CPAN seach for 'filesystem' before you came to this list,
right?

HTH,

-- jay
--------------------------------------------------
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org

values of β will give rise to dom!


Relevant Pages

  • Re: graceful script exit
    ... echo "Function 1 failed one or more times." ... Operating System and Devices", chapter 11, for ... > If I have a script with does a number of things like tars, ... even if some of the commands have succeeded. ...
    (AIX-L)
  • Re: Background Intelligence Transfer Service
    ... Could not start the Background Intelligence Transfer Service service ... This service is running and lists BITS as a dependent service. ... operating system is Windows XP Home Edition SP2, ...
    (microsoft.public.windowsxp.general)
  • Re: Another Hell Mutt Discussion
    ... of the lists. ... My field is operating system security. ... be seen as secure because nobody bothered taking a hard look at it. ...
    (rec.bicycles.tech)
  • Re: Help in checking the OS type...
    ... It lists me out the operating system name thanks for the same. ... I need to develop a script where in i need to first check the type ... Then the Total Space of each ...
    (perl.beginners)
  • Re: Think outside of the box (Gawd, I hate that term)
    ... > will never be one operating system that everyone uses. ... outside these lists. ... I have a Windows XP box and a Mac OS X machine at ... Cisco did its marketing job well (part of which was making good ...
    (freebsd-questions)