LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-12-2009, 04:11 AM   #16
manwithaplan
Member
 
Registered: Nov 2008
Location: ~/
Distribution: Arch || Sidux
Posts: 393

Original Poster
Rep: Reputation: 45

Here's the error.log output I piped out. I need to be clear that the file being extracted is stage3 install file. So I think that this might have some bearing in this output.

command used:
Code:
tr=$(tar -tvf *tar.bz2 2>&1 | wc -l) 
(
tar -xvf *tar.bz2 2>/tmp/error.log |  
awk '{ print int((Total+=1)/'$tr'*100); system("sleep 1")}' 
) |
dialog --gauge "Extracting...."  7 70
This test extraction is done in a contained environment. So there's no conflict with system files. And the dialog shows no progress because of the hang. The error output is confusing, because I think its referring to a conflict with my host system.

Bash output:
Code:
eternel test # tr=$(tar -tvf *tar.bz2 2>&1 | wc -l) 
eternel test # tar -xvf *tar.bz2 2>/tmp/error.log | awk '{ print int((Total+=1)/'$tr'*100); system("sleep 1")}'
0
0
0
0
0
0
0

Last edited by manwithaplan; 03-26-2009 at 08:33 PM.
 
Old 03-12-2009, 04:20 AM   #17
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
It is not an error, just a message from tar. However, what I wished to look at is the regular output passed to the dialog command. Please (be patient) post the output of the following:
Code:
tr=$(tar -tvf *tar.bz2 2>&1 | wc -l)
echo $tr
tar -xvf *tar.bz2 |  
awk '{ print int((Total+=1)/'$tr'*100)}'
Which version of tar is installed on this system?
 
Old 03-12-2009, 04:37 AM   #18
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Just seen the update to your post. Please post the output of the suggested lines of codes, too. The sequence of zeros is correct to me: since you are extracting a large file the result of int(small number/large number) is zero for a while. To me the command does not hung: it just requires a long time to go. In this case you can remove the sleep call (as I stated in my previous post, I used it just to test with a small archive).

The output looks correct, now. I suspect that a badly formatted output passed as input to dialog brought to a weird result, that is a wrong final percentage. Indeed, as stated in the man page:
Quote:
New percentages are read from standard input, one integer per line.
while in your previous examples, you got other than just a number per line and not integers.
 
Old 03-12-2009, 02:46 PM   #19
manwithaplan
Member
 
Registered: Nov 2008
Location: ~/
Distribution: Arch || Sidux
Posts: 393

Original Poster
Rep: Reputation: 45
Quote:
Originally Posted by colucix View Post
while in your previous examples, you got other than just a number per line and not integers.
You where exactly right, the output was correct, and I overlooked the man page regarding the reading of only integers. This shows my "awk" experience needs practice. Here is the output of your awk:

Code:
tr=$(tar -tvf *tar.bz2 2>&1 | wc -l)
tar -xvf *tar.bz2 | awk '{ print int((Total+=1)/'$tr'*100)}'

Prints errors... seen in error logs
counts integers till 99 then...
exits w/ tar: Exiting with failure status due to previous errors
#********

tr=$(tar -tvf *tar.bz2 2>&1 | wc -l)
echo $tr
38936
tar -xvf *tar.bz2 | awk '{ print int((Total+=1)/'$tr'*100)}'

Prints error... seen in error logs
counts integers till 99 then...
exits w/ tar: Exiting with failure status due to previous errors
#********

tr=$(tar -tvf *tar.bz2 2>&1 | wc -l)
echo $tr
38936
tar -xvf *tar.bz2 2>&1 | awk '{ print int((Total+=1)/'$tr'*100)}'

Prints no errors &
counts integers till 113
then exits. (Hence the output redirection 2>&1)
#********
After all of this I feel sheepish... because I re-looked at the original error output log. This is where I get sheepish. I've been running this in a user account w/ know root access. So it seems the 113 is the result of counting the additional line errors because of incorrect permissions. This is a stage3 extraction, which I use for creating custom builds. I deliberately do not use root because of containment. I've had issues in the past with using root & really messing things up on the host system, so I default user when testing. Unless needed for certain sbin commands.

So after rooting and trying your "int" it counts to 100 and exits. Perfectly... (no errors in log)

Thank you for your patience.
I am still working with awk, and its uses.

I also resolved my .git problem... Must have been tired when I was working on it.. overlooked simple syntax.

Last edited by manwithaplan; 03-12-2009 at 05:46 PM.
 
Old 03-12-2009, 05:50 PM   #20
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Quote:
Originally Posted by manwithaplan View Post
So after rooting and trying your "int" it counts to 100 and exits. Perfectly... (no errors in log)

Thank you for your patience.
I am still working with awk, and its uses.
Good! Now you have just to find a workaround for the permissions issues and avoid any error/warning from tar. A very good reference is the online manual, but remember to check the version installed on your system, since the GNU tar is still in active development and periodically they add new features.

Regarding awk, a must-read is the GNU Awk Programming Guide. A bit advanced, but if you carefully read the first two chapters, you are a step ahead!

Cheers!
 
Old 03-13-2009, 02:44 AM   #21
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
Actually you have been very wise not to login as root.
This is exactly what you should do. Login as root is only for when you have administrative task to do, like resizing filesystems, adding users, or installing software. You should not be working as root. It was a very good move.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
awk question on handling *.CSV "text fields" in awk jschiwal Programming 8 05-27-2010 07:23 AM
Sed/Awk: print lines between n'th and (n+1)'th match of "foo" xaverius Programming 17 08-20-2007 12:39 PM
dhcp says "wrong interface name: "ath0" Quakeboy02 Linux - Networking 10 12-19-2006 08:14 PM
Replacing "function(x)" with "x" using sed/awk/smth Griffon26 Linux - General 3 11-22-2006 11:47 AM
how can I invoke "awk" from shell to do floating point math? Joseph Schiller Programming 8 01-12-2006 06:00 AM


All times are GMT -5. The time now is 02:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration