SUMMARY: Perl scripting problem using tar...

From: McIntosh Alan-R54071 <alan_at_motorola.com>
Date: Tue Aug 27 2002 - 18:36:31 EDT
Mgrs,

Well, I was finally able to circumvent the limitations
of attempting to utilize 'tar' and 'pax' in the same
command line.

Larye Parkins offered the following suggestion:
	The standalone script takes standard input.  Perl does 
	not redirect its standard input to the subshell. 
	Do this: 
	-- cut here -- 
	#!/usr/bin/perl 

	open(TARBALL,"|/usr/sbin/tar cf - $thisfile | (cd 
	/home/GROUP; /usr/bin/pax -r -p e -s ',^/,,' )") 
	while(<>) { 
	print TARBALL; 
	} 
	close TARBALL; 

	-- cut here -- 

	this is the equivalent of the shell program: 
        cat - | tar cf - ... 
However, this produced the same errors as utilizing the
'system' call.  Thanks for your help anyway Larye!!

Solution:
I finally switched to a complete read/write using
'pax', I thought I had already done that, but I guess
not because it worked this time.

system("/usr/bin/pax -rw -t -p e -s ',^/,,' $thisfile /home/GROUP");

This worked without a hitch and retained all file
permissions and access times.

Thanks,
Alan

-----Original Message-----
From: McIntosh Alan-R54071 [mailto:alan@motorola.com]
Sent: Tuesday, August 27, 2002 8:44 AM
To: Sunmanagers (E-mail)
Subject: UPDATE: Perl scripting problem using tar...


Mgrs,

Sorry, I guess I should have been more descriptive
in what my actual goal was here.

What I am trying to determine is why the same command
works from the command line (with the exception of the
loss of permissions on directories, which I can live
with) but fails when doing a system call from a perl
script.

> perl script:
> system("/usr/sbin/tar cf - $thisfile | (cd /home/GROUP; 
> /usr/bin/pax -r -p e -s ',^/,,' )")

I think I also caused some confusion when I shortened the
actual directory location with '[path to directory]'.

> Errors received from perl script using pax:
> pax: [path to directory] : No such file or directory
> pax: [path to directory] : could not restore owner/group

This was due to the fact that it was about two lines long
( with the leading '/' removed at least! ).

I have received some suggestions of using 'cpio' and 'gtar',
but I have no experience with cpio and didn't want to have
to rely on gtar being installed on systems when used in the
future.

Thanks to the following people so far, I appreciate your
thoughts!

Edward Murphy
Josh Glover
Matt Hannigan
Lupe Christoph
Matt Garrett
Tom Payerle

Sincerely,
Alan McIntosh 
IT - UNIX Systems Administrator 
alan@motorola.com


-----Original Message-----
From: McIntosh Alan-R54071 [mailto:alan@motorola.com]
Sent: Monday, August 26, 2002 10:19 AM
To: Sunmanagers (E-mail)
Subject: Perl scripting problem using tar...


Mgrs,

I am having a very frustrating time trying to transfer 
files from one directory to another NFS mounted directory.
This same line of code works fine from the ksh scripts
I have always used, but I thought I would try writing it
in perl this time:

ksh script:
tar cf - $u | (cd /home/ACTIVE; tar xf -)

perl script:
system("/usr/sbin/tar cf - $thisfile | (cd /home/GROUP; 
/usr/bin/pax -r -p e -s ',^/,,' )")

I switched to using 'pax' to unpack the tar file because
tar was squawking about trying to un-tar the file, as well
as the need to strip off the leading slash because of the
problem having to use absolute tar 'packing'.

Errors received from perl script using pax:
pax: [path to directory] : No such file or directory
pax: [path to directory] : could not restore owner/group

The perl version works fine from the command line, with
exception of the loss of the original permissions on
directories only, files are fine?!

This is running on a Solaris 5.7 OS with various versions
of perl ranging from 5.004 to 5.6.1.

Thanks in advance for any help, will summarize!

Sincerely,
Alan McIntosh 
IT - UNIX Systems Administrator 
alan@motorola.com 
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Tue Aug 27 18:39:43 2002

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:42:53 EST