• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 521
  • Last Modified:

Need Unix script to tar directories and sub directories

I need a basic script which will tar up a directories and sub-directories plus send the the names of the files its taring to a log file which can be mailx'd to an email address. This tar will be scp'ed to another server and untared after the original files have been removed. Please let me know if you need anything else

Thanks,
7Souls
0
7Souls
Asked:
7Souls
1 Solution
 
ewest02Commented:
UNIX/linux way:

The basic command line

    tar cvf my_archive.tar dirX dirY subdirz  > my_archive_tar.log

or more compact and with mail option...

   tar cvf my_archive.tar dirX dirY subdirz  | mailx -s "archive log" user@foobar.com


Is this what you want???

#!/bin/sh
# usage:  cmd <tarfile name> <directory|subdir_path>...

tarfile=$1
shift

tar cvf ${tarfile} $* > my_archive_tar.log

cat my_archive_tar.log | mailx -s "my_archive_tar.log" user@foobar.com


Error handling left to student...
BTW what operating system and/or shell are you using???

  --Eric

0
 
7SoulsData Analyst/Database AdministratorAuthor Commented:
Eric,
Thanks, I apologize for not getting back to you sooner I've been away from work due to an injury. The operating system I'm using is Solaris SunOS 5.9 and I'm using Korn shell.. I'll send you a worikng copy of my script. Later,

Thanks,
7Souls
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now