[SunHELP] Perl with Solaris:Interaction whith OS --> System command or better ?

Jean Berthold jean.berthold at eos-gd.ch
Fri Jul 26 02:27:37 CDT 2002


Hello everybody,

This is my first post on this list ...
Currently I try to learn Perl language ...

I want to rewrite a Korn Shell script wich is make a full system backup,

by using the system tools available under Solaris 8: fssnap/ufsdump

The Korn Shell script does the following tasks:

1. The snapshot path is stored in the SnapRoot variable:
  SnapRoot=$(fssnap -F ufs -o backing-store=/home/SNAP /)
   Value for SnapRoot is now, for example: /dev/fssnap/3
   Return value for fssnap command is tested by :
  SnapRoot=$(fssnap -F ufs -o backing-store=/home/SNAP /)
  if (( $? != 0 ))
  then
    print "Erreur dans la creation du snapshot pour: /" >> $LOGFILE
    cat $LOGFILE | mailx -s "$SubjectAlarm" $MAILDEST
    exit 1
  fi
2. Dump is made directly on a tape:
   ufsdump 0f /dev/rmt/0n  $SnapRoot
   Return value for ufsdump is tested too :
   ufsdump 0f /dev/rmt/0n  $SnapRoot
   if (( $? != 0 ))
   ...
   ...

My perl script try to do the same things ... but :

I need to do that, (like for my shell-script) to get the value of the
path
of my snapshot in the SnapRoot variable:
my $SnapRoot =`fssnap -F ufs -o backing-store=/home/SNAP /`    ;

If I try to use the perl system function:
my $SnapRoot=system("fssnap -F ufs -o backing-store=/home/SNAP /");
SnapRoot variable will be filled by the return status from system( ).

I need to get return status for the fssnap command AND its value
(in my example: /dev/fssnap/3 ).

if ( ( system("fssnap ...") )  )
{
...
}
For testing the return value for this command that's  ok but I would
like
to store the backup path in the SnapRoot variable  ...

How to do that ?

If we need instruction like:
my $SnapRoot =`fssnap -F ufs -o backing-store=/home/SNAP /`    ;
(using backstits) I don't know where is the benefice to use perl instead

of shell scripts for theses tasks...

Thank for your help and have a nice day !

--
________________________________

Jean Berthold
EOS - energie ouest suisse
Chemin de Mornex 10 , CP 570
CH-1001 Lausanne , Switzerland
Tel. : +41 (0)21 341 24 58
Fax  : +41 (0)21 341 20 49
E-Mail : jean.berthold at eos-gd.ch
________________________________



More information about the SunHELP mailing list