- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: tar is sheel script problem !!!
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2008 03:20 AM
тАО07-08-2008 03:20 AM
tar is sheel script problem !!!
I have tried implementing the below commands in script.
1) su - $PROCESS -c "tar -tvf $file" | tee -a 2) $LOG/$file.log
su - $PROCESS <
exit
eof
The idea is to append the tar output in the log file.
The 2nd command captures the output however it capture the su copy righ information along the tar extract output, which I do not want.
Also it change the current shells stty setting once the script is completed.
Also I donot know how to put check for success/failure on tar extract
Kindly provide your suggestions and inputs.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2008 03:43 AM
тАО07-08-2008 03:43 AM
Re: tar is sheel script problem !!!
What's the content of $PROCESS? I'm assuming a user id.
As well is that the full syntax of your command? There's an unmatched ) in the line you provided.
The basic commands work:
tar -tvf $file | tee -a mylog.log
tar -xvf $file | tee -a mylog.log
Your error code is messed up because the tee statement follows it...so it's always successful.
If you only do tar -tvf somefilethatdoesntexist.tar
Then do echo $? you'll get a return code 255.
Any code > 0 means there was a problem.
Need more detail to be able to help. Specifically content of $PROCESS.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2008 03:48 AM
тАО07-08-2008 03:48 AM
Re: tar is sheel script problem !!!
I took the variables out and ran the above command specifying the user id and the logfile name.
The output of tar -tvf mytar.tar was successfully put into the log mylog.log.
Is that what you're trying to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2008 04:11 AM
тАО07-08-2008 04:11 AM
Re: tar is sheel script problem !!!
Also, create a script to run as the other user.
That would allow you to put the output exactly where you like. If you are going to put the output in that logfile, why send it to the stdout?
Don't always try to create one-liners.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2008 04:16 AM
тАО07-08-2008 04:16 AM
Re: tar is sheel script problem !!!
su - $PROCESS -c "tar -tvf $file" | tee -a $LOG/$file.log
You are right the $PROCESS is userid.
Strangely I get the list when I use tvf command but when I actually try to extract the output via xvf there is nothing written in the log file.
Thank you both for your prompt reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2008 04:21 AM
тАО07-08-2008 04:21 AM
Re: tar is sheel script problem !!!
I only use tee when I want to see the output at the same time it's logging to the file.
Otherwise just redirect via >> to append.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2008 04:22 AM
тАО07-08-2008 04:22 AM
Re: tar is sheel script problem !!!
su - $PROCESS -c "tar -tvf $file" | tee -a $LOG/$file.log
If you move that tee inside the quotes, you would have to write to a file that $PROCESS can't write.
For -tvf, why not read the file as you?
>but when I actually try to extract the output via xvf there is nothing written in the log file.
What is that command? The same except -xvf?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2008 04:43 AM
тАО07-08-2008 04:43 AM
Re: tar is sheel script problem !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2008 04:46 AM
тАО07-08-2008 04:46 AM
Re: tar is sheel script problem !!!
Kindly suggest if any modifications are required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2008 10:31 PM
тАО07-11-2008 10:31 PM
Re: tar is sheel script problem !!!
>chmod 775 $file
>chown $PROCESS:tarot $file
>chown -R $PROCESS:tarot $LOG/$file.log
>chmod 755 $LOG/$file.log
You shouldn't make these files executable. Nor is -R (recursive) needed for chown:
chmod 664 $file
chown $PROCESS:tarot $file
chown $PROCESS:tarot $LOG/$file.log
chmod 644 $LOG/$file.log
>#su - $PROCESS -c "tar -tvf $file" | tee -a $LOG/$file.log
No need to use "su -", remove the "-".
su - $PROCESS <
exit
eof
Again, no need to use "su -", remove the "-", but you need to cd to the home directory:
su $PROCESS <
tar -xvf $PATH2/$file | tee -a $LOG/$file.log
exit
eof