#!/opt/ras/perl/perl5
use FindBin;

sub prompt { 
  print "Enter password to crypt: ";
}

if ($ARGV[0]) {
  &cryptnsalt($ARGV[0]); 
} else {
  print "Allows to change the password of the Network Storage Agent web-server
Usage: save_password <password>\n";
}
exit;

sub cryptnsalt {
  my($pass) = @_;
  $pass1 = crypt($pass, ((sprintf("%x", time | $$)) =~ /(..)$/, $1));

  my($local_p) = $FindBin::Bin;
  my($ix) = rindex($local_p, "/");
  $HOME   = substr($local_p,0,$ix);

  open(O,">$HOME/System/password");
  print O $pass1;
  close(O);
}
