я на shell не программировал давно, за всю Одессу не скажу
но есть такое скрипты которые только на Си можно написать

например, события ядра FreeBSD или доступ к видео памяти... (хотя такие библиотеки уже готовые есть на Си в perl,ruby,python,etc)
т.е. тут вопрос субъективный...
Filesys::DiskSpace:
свободное места проверяет на разных ОС
http://cpansearch.perl.org/src/FTASSIN/ ... skSpace.pm
Код: Выделить всё
# known FS type numbers
my %fs_type = (
0 => "4.2", # 0x00000000
256 => "UFS", # 0x00000100
2560 => "ADVFS", # 0x00000A00
4989 => "EXT_SUPER_MAGIC", # 0x0000137D
4991 => "MINIX_SUPER_MAGIC", # 0x0000137F
5007 => "MINIX_SUPER_MAGIC2", # 0x0000138F
9320 => "MINIX2_SUPER_MAGIC", # 0x00002468
9336 => "MINIX2_SUPER_MAGIC2", # 0x00002478
19780 => "MSDOS_SUPER_MAGIC", # 0x00004d44
20859 => "SMB_SUPER_MAGIC", # 0x0000517B
22092 => "NCP_SUPER_MAGIC", # 0x0000564c
26985 => "NFS_SUPER_MAGIC", # 0x00006969
38496 => "ISOFS_SUPER_MAGIC", # 0x00009660
40864 => "PROC_SUPER_MAGIC", # 0x00009fa0
44543 => "AFFS_SUPER_MAGIC", # 0x0000ADFF
61265 => "EXT2_OLD_SUPER_MAGIC", # 0x0000EF51
61267 => "EXT2_SUPER_MAGIC", # 0x0000EF53
72020 => "UFS_MAGIC", # 0x00011954
19911021 => "_XIAFS_SUPER_MAGIC", # 0x012FD16D
19920820 => "XENIX_SUPER_MAGIC", # 0x012FF7B4
19920821 => "SYSV4_SUPER_MAGIC", # 0x012FF7B5
19920822 => "SYSV2_SUPER_MAGIC", # 0x012FF7B6
19920823 => "COH_SUPER_MAGIC", # 0x012FF7B7
4187351113 => "HPFS_SUPER_MAGIC", # 0xF995E849
);
sub df ($) {
my $dir = shift;
my ($fmt, $res, $type, $flags, $osvers, $w);
# struct fields for statfs or statvfs....
my ($bsize, $frsize, $blocks, $bfree, $bavail, $files, $ffree, $favail);
Carp::croak "Usage: df '\$dir'" unless $dir;
Carp::croak "Error: $dir is not a directory" unless -d $dir;
# try with statvfs..
eval { # will work for Solaris 2.*, OSF1 v3.2, OSF1 v4.0 and HP-UX 10.*.
{
package main;
require "sys/syscall.ph";
}
$fmt = "\0" x 512;
$res = syscall (&main::SYS_statvfs, $dir, $fmt) ;
# try with statfs..
|| eval { # will work for SunOS 4, Linux 2.0.* and 2.2.*
{
package main;
require "sys/syscall.ph";
}
$fmt = "\0" x 512;
$res = syscall (&main::SYS_statfs, $dir, $fmt);
# statfs...
|| eval {
{
package main;
require "sys/syscall.ph";
}
# The previous try gives an unknown fs type, it must be a different
# structure format..
$fmt = "\0" x 512;
# Try this : n2i7L119
$res = syscall (&main::SYS_statfs, $dir, $fmt);
($type, $flags, $bsize, $frsize, $blocks,
$bfree, $bavail, $files, $ffree) = unpack "n2i7", $fmt;
$res == 0 && defined $fs_type{$type};
}
# Neither statfs nor statvfs.. too bad.
|| eval {
$osvers = $Config{'osvers'};
$w = 0;
# These system normaly works but there was a problem...
# Trying to inform the user...
if ($^O eq 'solaris' || $^O eq 'dec_osf') {
# Tested. No problem if syscall.ph is present.
warn "An error occured. statvfs failed. Did you run h2ph?\n";
$w = 2;
}
if ($^O eq 'linux' || $^O eq 'freebsd') {
# Tested with linux 2.0.0 and 2.2.2
# No problem if syscall.ph is present.
warn "An error occured. statfs failed. Did you run h2ph?\n";
}
if ($^O eq 'hpux') {
if ($osvers == 9) {
# Tested. You have to change a line in syscall.ph.
warn "An error occured. statfs failed. Did you run h2ph?\n" .
"If you are using a hp9000s700, see the Df documentation\n";
}
elsif ($osvers == 10) {
# Tested. No problem if syscall.ph is present.
warn "An error occured. statvfs failed. Did you run h2ph?\n";
}
else {
# Untested
warn "An error occured. df failed. Please, submit a bug report.\n";
}
$w = 3;
}
$w;
}
|| Carp::croak "Cannot use df on this machine (untested or unsupported).";