using tar via su in a script issue !!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting using tar via su in a script issue !!!
# 1  
Old 07-02-2008
using tar via su in a script issue !!!

I am trying to implement the below command in my shell script

su - $PROCESS -c `tar -tvf $file|tee -a $LOG/$file.log`

The idea is to get the tar output on the screen and at the same time it should put the output in the log file.

Problem is:
1) I donot get the output on the screen.
2) After the script exits it unsets stty erase parameter for my local shell.

Thank you is advance for your valuable inputs.
# 2  
Old 07-02-2008
Try using " quotes, also you may as well do the tee part in the unprivileged shell, e.g.

Code:
su - $PROCESS -c "tar -tvf $file" | tee -a $LOG/$file.log

# 3  
Old 07-07-2008
Thank for your reply, I tried wt you told me to.
I won't only to the list of tar file and not the output as below which it is currently putting in the log file. Kinldy advise.

(c)Copyright 1983-2003 Hewlett-Packard Development Company, L.P.
(c)Copyright 1979, 1980, 1983, 1985-1993 The Regents of the Univ. of California
(c)Copyright 1980, 1984, 1986 Novell, Inc.
(c)Copyright 1986-2000 Sun Microsystems, Inc.
(c)Copyright 1985, 1986, 1988 Massachusetts Institute of Technology
(c)Copyright 1989-1993 The Open Software Foundation, Inc.
(c)Copyright 1990 Motorola, Inc.
(c)Copyright 1990, 1991, 1992 Cornell University
(c)Copyright 1989-1991 The University of Maryland
(c)Copyright 1988 Carnegie Mellon University
(c)Copyright 1991-2003 Mentat Inc.
(c)Copyright 1996 Morning Star Technologies, Inc.
(c)Copyright 1996 Progressive Systems, Inc.


RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the U.S. Government is subject to
restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in
Technical Data and Computer Software clause in DFARS 252.227-7013.


Hewlett-Packard Company
3000 Hanover Street
Palo Alto, CA 94304 U.S.A.

Rights for non-DOD U.S. Government Departments and Agencies are as set
forth in FAR 52.227-19(c)(1,2).
^[[3g ^[H ^[H ^[H ^[H ^[H ^[H ^[H ^[H ^[H ^[H ^[
H ^[H ^[H ^[H ^[H ^[H ^[H ^[H ^[Hrwxrwxr-x 924/45 17713880 Mar 28 12:34 2008 serv
er/TAMUA135
logout
# 4  
Old 07-07-2008
Since you don't need to load the user's environment settings, etc. from .profile for such a simple command, you can omit the - to prevent that, i.e.:

Code:
su $PROCESS -c "tar -tvf $file" | tee -a $LOG/$file.log

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issue with tar command

Hi all, I have a folder that I am trying to tar ut is leading to unexpected results. Ive written a script that find a certain number of files(logs) with specific names older than 14 days, moves them to a folder and compresses that folder. _ARCHIVE=/opt/test/archived_logs... (2 Replies)
Discussion started by: Junaid Subhani
2 Replies

2. Shell Programming and Scripting

Tar and un-tar issue

In AIX 5.3, I have these directories: /lms /lms/w_standard /lms/d_admin /lms/b_common /lms/b_prodbus /lms/d_prod /lms/d_prod/ccldir /lms/d_prod/ccluserdir /lms/d_prod/config /lms/d_prod/data /lms/d_prod/log /lms/d_prod/ocd /lms/d_prod/print /lms/d_prod/temp /lms/reg... (7 Replies)
Discussion started by: Daniel Gate
7 Replies

3. Shell Programming and Scripting

Issue in Untaring the Tar files Script

I have written a below script to untar the tar files from /tmp/tarfiles/ directory. # cat /tmp/tarfiles/script.sh #!/bin/sh cd /tmp/tarfiles/ TFL="tar_files_list.txt" TCF="tar_completed_list.txt" ls -l *.tar | awk '{print $9}' > $TFL for i in `cat $TFL` do if then for j in... (2 Replies)
Discussion started by: thomasraj87
2 Replies

4. UNIX for Advanced & Expert Users

Issue in extracting Tar and Zipped file.

Hi, I want to tar files and zip them in order to clean up space in directory. I have files like /path/file1 /path file2. What I am trying to do is: Option 1: tar -cvf /path/file1 /path file2 | gzip > test.tar.gz I got the file created. But while trying to extract the Tar and zipped file, I... (1 Reply)
Discussion started by: Quesemail
1 Replies

5. UNIX for Dummies Questions & Answers

TAR issue

Hello all, I was attempting to create a tar file via this command: tar cpf 20100529.tar | find . -name *20100529* Attempt to create archive of no files. Nothing dumped. which produced a list of several files in the .tar file but in the end the file was: -rw-r--r-- 1 xxx_xxxx users ... (9 Replies)
Discussion started by: riker
9 Replies

6. Shell Programming and Scripting

Tar file issue.

Hi all, I have couple of files I need to tar and put in some client server could some body help me the basic understanding of tarring files please It would be a great help. regards Anwar (4 Replies)
Discussion started by: Haque123
4 Replies

7. Shell Programming and Scripting

Tar archive issue

Hi, I make a tar archive: tar -czvf /path_to/cucu.tar.gz /path/dir_to_archive/ In the archive the /path/dir_to_archive/ is maintained for every file. I need that the archive to be made without the /path/dir_to_archive/ to contain only the files in /path/dir_to_archive/. Thanks,... (4 Replies)
Discussion started by: potro
4 Replies

8. Shell Programming and Scripting

tar issue

frnds, I compressed some files on the basic of $date var. $date contains todays date in some specific format.. also my files are in different directories... now, I m doing. tar -cvf archive.tar /root/abc/*$date* /root/wxv/123/*$date* /var/*$date* this creates archive.tar for me.. ... (4 Replies)
Discussion started by: clx
4 Replies

9. HP-UX

Tar command issue

I made tar file having file names more character( up to 50). When i extract file in Linux it extracts fine.. but in HPUX all file name which are more than 24 are trimed to 24 characters. i m using "tar -xvf xx.tar" i read some O and N option for New posix and Old but didnt got. :confused: ... (2 Replies)
Discussion started by: ajayyadavmca
2 Replies

10. UNIX for Dummies Questions & Answers

tar /dev/dat issue

Hi, I am trying to write to a dat tape, using HP UX 10.20 tar: cannot open /dev/dat not mounted ? ioscan ? if so, then where ? suggestions ? thanks simon (6 Replies)
Discussion started by: simon2000
6 Replies
Login or Register to Ask a Question