bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(Fwd) Restore problem


From: nomonde chilisa
Subject: (Fwd) Restore problem
Date: Fri, 24 Nov 2000 09:42:53 +0200

------- Forwarded Message Follows -------
From:                   Self <nomondec>
To:                     address@hidden
Subject:                Restore problem 
Send reply to:          address@hidden
Date sent:              Fri, 24 Nov 2000 09:39:03 +0200

please find enclosed a script that should restore from a tar archive 
into the original location; instead it triggers the error "tar: could not 
create directory : No such file or directory (ENOENT)" and restores 
the files into the directory that I am running the script from.
I have ensured that the original directory does exist. 
Please help urgently!!!!

# script to restore user documents from server archive
#

print "\n hash file read starting...";
%usrhash = readHash( "C:/sys/data/userinf.dat" );
print "\n hash file read finished...";

$name = $usrhash{"usrname"};
$docs = $usrhash{"usrdocs"};

$archive = "I:\\_system\\docsarch";

print "\nstarting user space restore.....\n";
print "tar -x -v -m -z -f$archive\n";
`cd $usrdocs`;
`$usrdocs`;
`tar -x -v -m -z -f$archive`;
print "\n...user space restore completed.";

# =====================
# subs
# =====================

sub readHash{ my( $fnam ) = @_;
        # reads hash file into hash table
        my( %usrhash, $assoc, $key, $val );
        local( $1, $2 );
        open( INF, $fnam ) || die "cannot open $fnam: $!";
        while( $assoc = <INF> )
        {       chomp( $assoc );
                if ($assoc =~ /\s*#.*/)
                {       # comment, do nothing
                }
                elsif ($assoc =~ /(.+?)=(.+)$/)
                {       $key = stripSpaces($1);
                        $val = stripSpaces($2);
                        if ($key && $val)
                        {       $usrhash{$key} = $val;
                                        print "\nok: <$key=$val>";
                        }
                        else
                        {       print "Illformed association <$key=$val>\n";
                        }
                }
        }
        close( INF );
        return %usrhash;
}

# =====================
# utils
# =====================

sub stripSpaces {
        local $1;
        if( @_[0]  =~ /^ \s* (.+?) \s* $/x )
        {       return $1;  }
        else
        {       return undef;  }
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]