Re: [gentoo-user] synchronize portage files in a LAN
From: CrÃstian Viana To: gentoo-user@lists.gentoo.org Sent: Sunday, November 22, 2009 10:32 PM Subject: [gentoo-user] synchronize portage files in a LAN hi, I have 7 computers in local network and I want them to have always the same portage files (the ones synchronized with rsync). of course I can use crontab to make them sync at a specific time but I'm wondering if there's a better alternative. I saw a wiki page which says to create one local rsync server and have the other 6 computers synchronize with it (by pointing the SYNC variable to the local rsync server). but I also thought NFS could be nice: I just have to sync one machine and everyone will always be synchronized. what's the best approach for this case? thanks! -- CrÃstian Deives dos Santos Viana [aka CD1] -- The options you mentioned is the best...Just settup the rsync server on the machine you want it on and then setup a cront job to update it daily. Set your 6 hosts to use your local rsync server machine and create cron jobs for the 6 machines. Just make sure that their cron jobs are 5-10 minutes ahead of when the local rsync server updates it's files.
Re: [gentoo-user] Blocking login attempts to sshd and vsftpd
- Original Message - From: KH gentoo-u...@konstantinhansen.de To: gentoo-user@lists.gentoo.org Sent: Sunday, November 15, 2009 6:22 AM Subject: Re: [gentoo-user] Blocking login attempts to sshd and vsftpd Richard Marza schrieb: I recently check my log files and discovered that there was a dictionary attack attempt on my daemons. sshd and vsftpd were the primary targets. Is there a script or tool to block the offending IP addresses using iptables. Something that checks to see if a minimum of attempts has occured and blocks them indefinitely based on that? Regards, Richard M. Hi, I am using that script: http://blinkeye.ch/dokuwiki/doku.php/projects/blacklist kh This is perfect and more straight-forward than the alternatives. I'm surprised this isn't one of the most mentioned or talked about in the threads. Thank you all.
[gentoo-user] Blocking login attempts to sshd and vsftpd
I recently check my log files and discovered that there was a dictionary attack attempt on my daemons. sshd and vsftpd were the primary targets. Is there a script or tool to block the offending IP addresses using iptables. Something that checks to see if a minimum of attempts has occured and blocks them indefinitely based on that? Regards, Richard M.
Re: [gentoo-user] Blocking login attempts to sshd and vsftpd
- Original Message - From: Alan McKinnon alan.mckin...@gmail.com To: gentoo-user@lists.gentoo.org Sent: Saturday, November 14, 2009 5:42 PM Subject: Re: [gentoo-user] Blocking login attempts to sshd and vsftpd On Saturday 14 November 2009 23:49:23 Richard Marza wrote: I recently check my log files and discovered that there was a dictionary attack attempt on my daemons. sshd and vsftpd were the primary targets. Is there a script or tool to block the offending IP addresses using iptables. Something that checks to see if a minimum of attempts has occured and blocks them indefinitely based on that? There are HUNDREDS of such solutions out there. Did you even try to Google first? fail2ban denyhosts are quite popular and get the job done. OSSEC is a full blown IDS that I use at work, it functions very well but is probably overkill for your needs. Last hint: You do NOT want to block hosts permanently. Your logs will empty sure enough, but sooner or later you will lock yourself out, or you will lock out people you really do want to access your services. -- alan dot mckinnon at gmail dot com Thank you for the information, I did find that denyhost and fail2ban in threads but there were issues with it not working properly. Some users created custom scripts to get the job done correctly. I did try google. I guess it's no longer my friend. Will try to use another search engine next time.
Re: [gentoo-user] Re: kernel panic -- finding proper config diff
- Original Message - From: walt w41...@gmail.com To: gentoo-user@lists.gentoo.org Sent: Friday, October 23, 2009 6:54 PM Subject: [gentoo-user] Re: kernel panic -- finding proper config diff On 10/23/2009 02:57 PM, Maxim Wexler wrote: not an idea really but further experience Since LiveDvD-10.1 boots, albeit buggily, on the netbook. I tried to use the kernel config provided with it. I ran make oldconfig then opened up the menu and whittled away the extraneous modules, built the new kernel, installed it and rebooted. This time, after a flurry of red exclamation points, it reached the login and crashed there. Well, whatever changes you made to .config fixed the original panic, so I'd start by diff'ing the first .config with the new .config (or post the new .config here). No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.423 / Virus Database: 270.14.28/2454 - Release Date: 10/23/09 14:09:00 For which netbook are trying to compile a kernel for?
Re: [gentoo-user] Desperately seeking modelines; xorg 1.6.3.901-r2bleeds off the edges
- Original Message - From: Kevin O'Gorman To: gentoo-user@lists.gentoo.org Sent: Saturday, October 17, 2009 2:42 PM Subject: Re: [gentoo-user] Desperately seeking modelines; xorg 1.6.3.901-r2bleeds off the edges On Sat, Oct 17, 2009 at 11:03 AM, Dirk Heinrichs dirk.heinri...@online.de wrote: Am Samstag 17 Oktober 2009 19:21:46 schrieb Kevin O'Gorman: My Xorg.conf does specify some details about the monitor, but no modeline. I had to put that stuff in there originally to get my preferred 1280x1024 resolution. Do I need to go back to the days of modlines? Xorg.conf is attached. Did you try X -configure? Or even without xorg.conf? Bye... Dirk I did. I was forced to by the behavior of X without them. That whole thing started out as the results of X -configure. -- Kevin O'Gorman, PhD -- No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.421 / Virus Database: 270.14.20/2441 - Release Date: 10/16/09 18:39:00 Just use gtf to get your desired modeline.
Re: [gentoo-user] Desperately seeking modelines; xorg 1.6.3.901-r2bleeds off the edges
- Original Message - From: Kevin O'Gorman To: gentoo-user@lists.gentoo.org Sent: Saturday, October 17, 2009 2:58 PM Subject: Re: [gentoo-user] Desperately seeking modelines; xorg 1.6.3.901-r2bleeds off the edges On Sat, Oct 17, 2009 at 10:29 AM, Volker Armin Hemmann volkerar...@googlemail.com wrote: On Samstag 17 Oktober 2009, Kevin O'Gorman wrote: I normally stay logged in forever, even after updates. I'm both busy and lazy. However, the Xorg flurry seemed to have died down, so I took the plunge and rebooted. Oops. troll option=ignore It had not re-emerged xf86-input-* for me, a case that I think should be handled automatically -- I use a source distro because I want to be able to tweak it, not so that it can force me to do so at arbitrary, inconvenient and unpredictable intervals. /troll gentoo is about 'doing it yourself' and 'emancipation of the user' and not about 'holding your hand'. It is not gentoo's fault if you act stupid. My Xorg.conf does specify some details about the monitor, but no modeline. I had to put that stuff in there originally to get my preferred 1280x1024 resolution. Do I need to go back to the days of modelines? Xorg.conf is attached. Section Monitor Identifier Monitor0 VendorName WDE ModelNameLCM-20v5 Option DPMS EndSection ? Opinions differ about what constitutes stupidity. I'm not much interested in yours and I don't speak about mine, in part because neither one clarifies anything. Opinions about usefulness are another matter. Why not dispense with portage and have everyone compile their own from tarballs -- just publish a list of packages and patches; then you'd really not be holding hands. It seems to be a matter of degrees and judgement. Modifying the monitor section made no noticeable change. There's still a 24-pixel bleed off the right edge to begin with. I can fool with settings to make it bleed left instead, but there's no setting that affects pixel spacing. I like the cleaner monitor section, though. I'm back to thinking about modelines. Any better ideas? -- Kevin O'Gorman, PhD -- No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.421 / Virus Database: 270.14.20/2441 - Release Date: 10/16/09 18:39:00 Let's not rule-out the possibility that this might be an issue with a bad video card. I once thought I had a bad monitor because of horizontal and vertical bleeding and it turned out to be the video card. Try the modelines, if it does not work, swap video cards. Below is a section pertaining to modelines from my config. User gtf to generate proper modelines for your monitor. you can omit the identifier if you don't have a 22 inch minitor. Section Modes Identifier 16:10 # # Modelines for attached projectors. # Occasionally in town halls you meet ancient donated projectors # that can cope only with low resolutions. # # HorxVer @ clock hsync = clock * Vtotpclk = hsync * Htot # ModeLineHorxVer pclk Hor Hstart Hend Htot Ver Vstart Vend Vtot [Interlace] # # 640x480 @ 60.00 Hz (GTF) hsync: 31.50 kHz; pclk: 25.20 MHz # ModeLine640x480 25.20 640 664 760 800 480 491 493 525 # # 800x600 @ 60.00 Hz (GTF) hsync: 37.68 kHz; pclk: 39.79 MHz # ModeLine800x600 39.79 800 856 1040 1056 600 600 616 628 # # 1024x768 @ 60.00 Hz (GTF) hsync: 48.36 kHz; pclk: 65.00 MHz # ModeLine1024x768 65.00 1024 1032 1176 1344 768 771 777 806 # # 1024x768 @ 60.00 Hz (GTF) hsync: 29.97 kHz; pclk: 37.88 MHz # ModeLine1024x768 37.88 1024 1048 1208 1264 768 776 784 999 Interlace # # Modelines for the native 16:10 LCD screen. # # 1280x800 @ 60.00 Hz (GTF) hsync: 49.68 kHz; pclk: 83.46 MHz ModeLine1280x800 83.46 1280 1344 1480 1680 800 801 804 828 # # 1680x1050 @ 60.00 Hz (GTF) hsync: 63.84 kHz; pclk: 144.02 MHz Modeline 1680x1050_75.00 188.07 1680 1800 1984 2288 1050 1051 1054 1096 -HSync +Vsync EndSection
Re: [gentoo-user] Desperately seeking modelines; xorg 1.6.3.901-r2bleeds off the edges
- Original Message - From: Kevin O'Gorman To: gentoo-user@lists.gentoo.org Sent: Saturday, October 17, 2009 3:26 PM Subject: Re: [gentoo-user] Desperately seeking modelines; xorg 1.6.3.901-r2bleeds off the edges On Sat, Oct 17, 2009 at 12:18 PM, Alan McKinnon alan.mckin...@gmail.com wrote: On Saturday 17 October 2009 20:58:00 Kevin O'Gorman wrote: Modifying the monitor section made no noticeable change. There's still a 24-pixel bleed off the right edge to begin with. I can fool with settings to make it bleed left instead, but there's no setting that affects pixel spacing. I like the cleaner monitor section, though. I'm back to thinking about modelines. Any better ideas? I'd try adjust the frequencies first, then try modelines. -- alan dot mckinnon at gmail dot com I'd try that too if I had a clue how to do it, let alone do it safely. Got any pointers to FMs? If you have a flat panel it will not mess up your monitor because they have safeguards against that and also modelines don't go in the monitor or screens section...they go in the modes section...did u try what i mentioned in my last post.
Re: [gentoo-user] Desperately seeking modelines; xorg 1.6.3.901-r2bleeds off the edges
Original Message - From: Kevin O'Gorman To: gentoo-user@lists.gentoo.org Sent: Saturday, October 17, 2009 3:42 PM Subject: Re: [gentoo-user] Desperately seeking modelines; xorg 1.6.3.901-r2bleeds off the edges On Sat, Oct 17, 2009 at 12:34 PM, Alan McKinnon alan.mckin...@gmail.com wrote: On Saturday 17 October 2009 21:26:41 Kevin O'Gorman wrote: On Sat, Oct 17, 2009 at 12:18 PM, Alan McKinnon alan.mckin...@gmail.comwrote: On Saturday 17 October 2009 20:58:00 Kevin O'Gorman wrote: Modifying the monitor section made no noticeable change. There's still a 24-pixel bleed off the right edge to begin with. I can fool with settings to make it bleed left instead, but there's no setting that affects pixel spacing. I like the cleaner monitor section, though. I'm back to thinking about modelines. Any better ideas? I'd try adjust the frequencies first, then try modelines. -- alan dot mckinnon at gmail dot com I'd try that too if I had a clue how to do it, let alone do it safely. Got any pointers to FMs? Safe frequency ranges are in the monitor's documentation. Do you have docs for your monitor (I'm using it's a CRT). You can safely reduce either horiz or vert range. As the electronics[1] age, the monitor's ability to correctly sync the start of the picture with the start of the display area deteriorates, especially at the upper bound. If reducing the upper bound of the horiz setting improves matters, that is indicative of this happening. [1] more specifically, electrolytic capacitors. They are temperature- sensitive. Silicon does not wear out as such. -- alan dot mckinnon at gmail dot com I have docs. They are not very informative. When I start it up, the left edge is fine, which is the sync edge. Because of that and because I can adjust positioning left and right, and because the problem arose abruptly with the reboot to a new Xorg, I rate the probability of hardware problems low (but not zero of course). It appears to be a problem of horizontal spacing of the pixels. At it stands there is not room for the last 24. -- Kevin O'Gorman, PhD -- No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.421 / Virus Database: 270.14.20/2441 - Release Date: 10/16/09 18:39:00 What type of monitor do you have? How old is it? What is the screen size? What exactly do you mean by bleeding edges? Does the gui scroll when you move you mouse towards the edges? is that what you mean by bleeding? Another thing; Do you have the monitor manual? It will tell you the proper H and V sync rates at certain resolutions. Are you sure it supports that resolution?
Re: [gentoo-user] Desperately seeking modelines; xorg1.6.3.901-r2bleeds off the edges
- Original Message - From: Kevin O'Gorman To: gentoo-user@lists.gentoo.org Sent: Saturday, October 17, 2009 3:51 PM Subject: Re: [gentoo-user] Desperately seeking modelines; xorg1.6.3.901-r2bleeds off the edges On Sat, Oct 17, 2009 at 12:39 PM, Richard Marza richardmar...@optonline.net wrote: - Original Message - From: Kevin O'Gorman To: gentoo-user@lists.gentoo.org Sent: Saturday, October 17, 2009 3:26 PM Subject: Re: [gentoo-user] Desperately seeking modelines; xorg 1.6.3.901-r2bleeds off the edges On Sat, Oct 17, 2009 at 12:18 PM, Alan McKinnon alan.mckin...@gmail.com wrote: On Saturday 17 October 2009 20:58:00 Kevin O'Gorman wrote: Modifying the monitor section made no noticeable change. There's still a 24-pixel bleed off the right edge to begin with. I can fool with settings to make it bleed left instead, but there's no setting that affects pixel spacing. I like the cleaner monitor section, though. I'm back to thinking about modelines. Any better ideas? I'd try adjust the frequencies first, then try modelines. -- alan dot mckinnon at gmail dot com I'd try that too if I had a clue how to do it, let alone do it safely. Got any pointers to FMs? If you have a flat panel it will not mess up your monitor because they have safeguards against that and also modelines don't go in the monitor or screens section...they go in the modes section...did u try what i mentioned in my last post. It's a flat panel. I did not know what to do with your last post, as the modelines were not acceptable. The actual rates the monitor is showing now are 54.2KHz and 60.2Hz, which are well within specs. I chose the section from memory. In the pre-Xorg-pre-XFree days I seem to recall using different modelines at different depths. Modes section all by itself, not a subsection? I'll try that. -- Kevin O'Gorman, PhD -- No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.421 / Virus Database: 270.14.20/2441 - Release Date: 10/16/09 18:39:00 If it was a subsection my post would have stated EndSubSection or something similar...Place the modes section after the InputDevice Section. Get your own modes...using gtf and slip them into the modes section like so: Section Modes Identifier 16:10 you modeline here EndSection But remember, you can leave out or specify the identifier ratios depending on whether it will work for you or not.
Re: [gentoo-user] Desperately seeking modelines; xorg1.6.3.901-r2bleeds off the edges
- Original Message - From: Kevin O'Gorman To: gentoo-user@lists.gentoo.org Sent: Saturday, October 17, 2009 4:11 PM Subject: Re: [gentoo-user] Desperately seeking modelines; xorg1.6.3.901-r2bleeds off the edges On Sat, Oct 17, 2009 at 12:56 PM, Richard Marza richardmar...@optonline.net wrote: Original Message - From: Kevin O'Gorman To: gentoo-user@lists.gentoo.org Sent: Saturday, October 17, 2009 3:42 PM Subject: Re: [gentoo-user] Desperately seeking modelines; xorg 1.6.3.901-r2bleeds off the edges On Sat, Oct 17, 2009 at 12:34 PM, Alan McKinnon alan.mckin...@gmail.com wrote: On Saturday 17 October 2009 21:26:41 Kevin O'Gorman wrote: On Sat, Oct 17, 2009 at 12:18 PM, Alan McKinnon alan.mckin...@gmail.comwrote: On Saturday 17 October 2009 20:58:00 Kevin O'Gorman wrote: Modifying the monitor section made no noticeable change. There's still a 24-pixel bleed off the right edge to begin with. I can fool with settings to make it bleed left instead, but there's no setting that affects pixel spacing. I like the cleaner monitor section, though. I'm back to thinking about modelines. Any better ideas? I'd try adjust the frequencies first, then try modelines. -- alan dot mckinnon at gmail dot com I'd try that too if I had a clue how to do it, let alone do it safely. Got any pointers to FMs? Safe frequency ranges are in the monitor's documentation. Do you have docs for your monitor (I'm using it's a CRT). You can safely reduce either horiz or vert range. As the electronics[1] age, the monitor's ability to correctly sync the start of the picture with the start of the display area deteriorates, especially at the upper bound. If reducing the upper bound of the horiz setting improves matters, that is indicative of this happening. [1] more specifically, electrolytic capacitors. They are temperature- sensitive. Silicon does not wear out as such. -- alan dot mckinnon at gmail dot com I have docs. They are not very informative. When I start it up, the left edge is fine, which is the sync edge. Because of that and because I can adjust positioning left and right, and because the problem arose abruptly with the reboot to a new Xorg, I rate the probability of hardware problems low (but not zero of course). It appears to be a problem of horizontal spacing of the pixels. At it stands there is not room for the last 24. -- Kevin O'Gorman, PhD -- No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.421 / Virus Database: 270.14.20/2441 - Release Date: 10/16/09 18:39:00 What type of monitor do you have? How old is it? What is the screen size? What exactly do you mean by bleeding edges? Does the gui scroll when you move you mouse towards the edges? is that what you mean by bleeding? Another thing; Do you have the monitor manual? It will tell you the proper H and V sync rates at certain resolutions. Are you sure it supports that resolution? It's as listed in the xorg.conf above: I can be sure because it's Westinghouse. It's a flat-screen. It's a couple of years old, I guess. It's new enough to talk to X and report: (II) MACH64(0): clock: 121.8 MHz Image Size: 410 x 308 mm which agrees with my ruler. In inches a little over 16 x 12 visible. The video card is sending all 1280 dot columns. I have a control on the monitor called H position and I can scroll one pixel at a time to change which 1256 dot columns I want to see of the 1280 that are sent. The image does not scroll with mouse movement. I have the manual. You are way over-optimistic about its contents. I had no better luck on the web site. The limits I've posted were acquired by X from the monitor itself. The monitor did fine until I rebooted yesterday. Its on-screen display shows it thinks it's doing 1280x1...@60hz. It's close of course, but not quite there. -- Kevin O'Gorman, PhD -- No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.421 / Virus Database: 270.14.20/2441 - Release Date: 10/16/09 18:39:00 So It's a flat-screen and not a flat panel lcd monitor? I think I'm beginning to understand your issue... setup the modelines like i told you and then check the monitor on-screen display settings. It seems it's not a modeline issue because modelines are primarily used to adjust
[gentoo-user] Bash Script that wraps Mplayer/Mencoder.
I have a script currently called rip that rips DVDs to H.264 using x264 with mencoder. It always does 2 passes and runs 2 threads(uses two cores). It has many lines but I'm sure if we work together we can shorten the number of lines and add more functionality. Uhm...for now, it does what it is supposed to do. It could use a little bit more functionality but it is user friendly once you have the right tools installed. It uses mplayers crop-detection feature to crop black bands out of the video. It requires libdvdread, lsdvd, mencoder/mplayer with x264, sed and of course bash. Here is the syntax below: ./rip.s dvd_device bitrate movie_name audio_id title Examples: ./rip.sh /dev/sr0 1200 Movie_Name 128 1 This will rip title 1 from device /dev/sr0 and place the video files into MovieName directory. The resulting file will be Movie_Name.avi. or if you have a range of titles to rip you can also specify this like so: ./rip.sh /dev/sr0 1200 Movie_Name 128 1-3 or if you don't know which title... It'll choose the longest title for you with the trailing option below. Just change the title field to auto ./rip.sh /dev/sr0 1200 Movie_Name 128 auto If you're not sure what the options are just run the script without any options. It will tell you if you can't remember or are not sure. I created the script because Acidrip ceased to work after a while. It no longer does what it used to do. Maybe it'll work on older distributions. In summary, Acidrip has not been updated to use the latest libraries. My script has much less of the functionality that Acidrip once had but it gets the job done. If anyone is interested please let me know and I will most definitely post it here. I look forward to porting this to python one day and calling it Acidripy using pygtk. Thank you for reading. I look forward to hearing from you guys.
Re: [gentoo-user] Re: Cloning movie DVDs with dd - only works after accessing disk with another command?
- Original Message - From: Stroller strol...@stellar.eclipse.co.uk To: gentoo-user@lists.gentoo.org Sent: Tuesday, August 11, 2009 4:22 PM Subject: Re: [gentoo-user] Re: Cloning movie DVDs with dd - only works after accessing disk with another command? On 11 Aug 2009, at 20:31, Grant Edwards wrote: On 2009-08-11, Stroller strol...@stellar.eclipse.co.uk wrote: I'm just really curious why `dd` works perfectly fine the last time, but not the first. Hasn't this been answered several times already? No, it hasn't. Presumably it works the second time but not the first time because between the two attempts you've run a program that has written the decryption keys to the optical drive. I'm just looking for a better answer than ones prefaced with presumably and which treat DeCSS encryption like it's black magic. I don't say that to offend anyone, because I'm sure none of the other posters doing so are claiming to be experts on the subject, either. Presumably anyone replying saying oh, it must be something like this is interested in discussing their conjecture. If you disagree with that answer, please esplain why rather than just re-asking the question again and again. Well, in the case of the message you quoted, the poster seemed not to have read the cloning.txt console log I posted. He seemed to be telling me that what I have done is impossible and I was correcting his misunderstanding. You will see that I already explained in my message of 11 August 2009 19:58:11 BST some aspects of this still confuse me. If you'd like me to clarify that post further then I guess the best way I can explain it is: if I've run a program that has written the decryption keys to the optical drive (your words), how come mplayer still has to retrieve the CSS keys (see cloning.txt) when it's run on the disc.iso file? (using -dvd-device argument) The answer to that is surely because the movie is still encrypted, so (to me) that begs the question why's the movie file still encrypted if I've written the decryption keys to the optical drive? This seems to me to be a logical loop, and I'd really be genuinely glad for someone to explain where I'm looking at it wrong (but please ignore this message if the subject is bothering you). I suspect someone who really understands what's going on here doesn't need the additional clarification of my previous 2 paragraphs. There's probably a really simple explanation for what's going on here. Stroller. To copy dvd to your p.c. just use mplayer/mencoder...It's not that difficult. It shouldn't be too difficult to get the dump back onto DVD disk. It's not that big of a deal. dd probably worked because the disk wasn't encrypted. Run the history command and investigate. This could have been a fluke. It's nothing to ramble on about.
[gentoo-user] Bash script inquiry
I'm trying to run a command in a loop. I have a counter device set...the number that the counter generates is supposed to go inside the command in the loop after every successive iteration of the loop. This is all really to get a general idea I've attached a snippet below. FILE=`cat filename.txt` TICK=`cat filename.txt | wc -l' TOCK=0 while [ $TICK != $TOCK ] ; do let $TOCK=$TOCK+1 Var1= `cat FirstWordOfFirstColumnOfFirstLine` (This I actually achieved with sed and awk) Var2=`cat FirstFloatOfFirstLine` (The problem lies here; it's my inability to come up with a way of implementing a variable that changes along with the counter. so that the second time this is run it doesn't do the first line but moved to the second line and the third line and so on...) done exit 0 My file is like so: VariableSys1Sys2Sys3Sys4 Sys5 Dbase1 5.0 4.6 5.6 6. 6 .004
Re: [gentoo-user] Bash script inquiry
- Original Message - From: Alex Schuster wo...@wonkology.org To: gentoo-user@lists.gentoo.org Sent: Tuesday, August 11, 2009 4:59 AM Subject: Re: [gentoo-user] Bash script inquiry Richard Marza writes: FILE=`cat filename.txt` TICK=`cat filename.txt | wc -l' TOCK=0 while [ $TICK != $TOCK ] ; do let $TOCK=$TOCK+1 Or, simpler, as we are using bash: (( TOCK++ )) Var1= `cat FirstWordOfFirstColumnOfFirstLine` (This I actually achieved with sed and awk) Var2=`cat FirstFloatOfFirstLine` (The problem lies here; it's my inability to come up with a way of implementing a variable that changes along with the counter. so that the second time this is run it doesn't do the first line but moved to the second line and the third line and so on...) done exit 0 What should Var1 contain - Dbase1 or the content of the file Dbase1? What should Var2 contain - 5.0or the content of the file 5.0? Because you are using cat in the assignment. If you just need the values in a variable, do it like this: file=filename.txt Var1=( $( cat $file | awk '{ print $1 }' ) ) # creates an array variable Var2=( $( cat $file | awk '{ print $2 }' ) ) The $() notation does the same as backticks, but is more readable. Using foo=( ... ) will create foo as an array. I assume there is no whitespace in your data, that is Var1 will never contain something like Dbase 1. ${#va...@]} will contain the number of elements (your $TICK). To access the 5th element (for example), use ${Var1[4]}. Oh, an please don't hijack threads by replying to an existing one, but start a new one. This one appears inside the Cloning movie DVDs thread. And feel free to ask more questions, maybe I got it all wrong. Wonko I did not intend to hijack. Next time I will be more cautious. Your information is useful. I have used awk. The array is very useful here. Think of the file I'm using as a spreadsheet. The headers(column names) are on top and the values are below them. Each line has an item with multiple values under different systems. Item System1 System3 System4 ... nio5.05.55.0(these are individual values. They are nothing more than what they represent. The item (nio) and the float or integer representing its value under the different system...It's just a file) My goal is to take nio and figure out which system has a different price than the others. So if the script were to run through 200 lines of similar text it should definitely kick-out: nio has discrepancy in System3; price 5.5 in line 1 Another thing, all systems can have different prices. This must also kick out. This is really a script to report discrepancies.
[gentoo-user] Bash script inquiry (this is a dup: sorry for the hijack)
- Original Message - From: Alex Schuster wo...@wonkology.org To: gentoo-user@lists.gentoo.org Sent: Tuesday, August 11, 2009 4:59 AM Subject: Re: [gentoo-user] Bash script inquiry Richard Marza writes: FILE=`cat filename.txt` TICK=`cat filename.txt | wc -l' TOCK=0 while [ $TICK != $TOCK ] ; do let $TOCK=$TOCK+1 Or, simpler, as we are using bash: (( TOCK++ )) Var1= `cat FirstWordOfFirstColumnOfFirstLine` (This I actually achieved with sed and awk) Var2=`cat FirstFloatOfFirstLine` (The problem lies here; it's my inability to come up with a way of implementing a variable that changes along with the counter. so that the second time this is run it doesn't do the first line but moved to the second line and the third line and so on...) done exit 0 What should Var1 contain - Dbase1 or the content of the file Dbase1? What should Var2 contain - 5.0or the content of the file 5.0? Because you are using cat in the assignment. If you just need the values in a variable, do it like this: file=filename.txt Var1=( $( cat $file | awk '{ print $1 }' ) ) # creates an array variable Var2=( $( cat $file | awk '{ print $2 }' ) ) The $() notation does the same as backticks, but is more readable. Using foo=( ... ) will create foo as an array. I assume there is no whitespace in your data, that is Var1 will never contain something like Dbase 1. ${#va...@]} will contain the number of elements (your $TICK). To access the 5th element (for example), use ${Var1[4]}. Oh, an please don't hijack threads by replying to an existing one, but start a new one. This one appears inside the Cloning movie DVDs thread. And feel free to ask more questions, maybe I got it all wrong. Wonko I did not intend to hijack. Next time I will be more cautious. Your information is useful. I have used awk. The array is very useful here. Think of the file I'm using as a spreadsheet. The headers(column names) are on top and the values are below them. Each line has an item with multiple values under different systems. Item System1 System3 System4 ... nio5.05.55.0(these are individual values. They are nothing more than what they represent. The item (nio) and the float or integer representing its value under the different system...It's just a file) My goal is to take nio and figure out which system has a different price than the others. So if the script were to run through 200 lines of similar text it should definitely kick-out: nio has discrepancy in System3; price 5.5 in line 1 Another thing, all systems can have different prices. This must also kick out. This is really a script to report discrepancies. Hopefully this one does not appear to be hijacked. If it is let me know and I'll stop the discussion with regards to my inquiry. Thank you.
Re: [gentoo-user] Bash script inquiry
- Original Message - From: Etaoin Shrdlu shr...@unlimitedmail.org To: gentoo-user@lists.gentoo.org Sent: Tuesday, August 11, 2009 5:55 AM Subject: Re: [gentoo-user] Bash script inquiry On Tuesday 11 August 2009 10:27:26 Richard Marza wrote: Think of the file I'm using as a spreadsheet. The headers(column names) are on top and the values are below them. Each line has an item with multiple values under different systems. Item System1 System3 System4 ... nio5.05.55.0(these are individual values. They are nothing more than what they represent. The item (nio) and the float or integer representing its value under the different system...It's just a file) My goal is to take nio and figure out which system has a different price than the others. So if the script were to run through 200 lines of similar text it should definitely kick-out: nio has discrepancy in System3; price 5.5 in line 1 Another thing, all systems can have different prices. This must also kick out. This is really a script to report discrepancies. As I suspected, you can do the whole thing in awk only. Basically, I'm going to assume you want to report items which don't have all the same values on all systems. It's easy to spot those, but it might not be as easy to determine which values are the normal ones and which are the discrepant ones, especially if for example each system has a different value. You have to provide additional logic to tell the discrepant values from the others. For the moment, the script just prints out the lines where all the columns don't have the same value. awk 'NR==1{print;next}{for(i=3;i=NF;i++){if($i!=$2){print;break}}}' file.txt This is great. But it is important that I find which system has a mismatch for each item. I guess this is where loops and if statements come in. I believe I have sufficient information. Although, more discussion is welcome. Thank you all.