Re: [CentOS] Shell Script Help
Matt wrote: I have a script file in my cron.hourly that contains a good number of scripts I must call. #!/bin/sh sleep 15 perl /scripts/create_graph.pl sleep 15 perl /scripts/create_graph_out.pl many more lines. etc. Is there a way I can sleep random length to time before executing each but background each one so master script returns promptly. Something like. sleep 15 perl /scripts/create_graph.pl should return promptly, another reply addresses the random part. ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Help
On Fri, Sep 6, 2013 at 8:44 AM, Nicolas Thierry-Mieg nicolas.thierry-m...@imag.fr wrote: Matt wrote: I have a script file in my cron.hourly that contains a good number of scripts I must call. #!/bin/sh sleep 15 perl /scripts/create_graph.pl sleep 15 perl /scripts/create_graph_out.pl many more lines. etc. Is there a way I can sleep random length to time before executing each but background each one so master script returns promptly. Something like. sleep 15 perl /scripts/create_graph.pl should return promptly, another reply addresses the random part. sleep $(($RANDOM%300)) ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
[CentOS] Shell Script Help
I have a script file in my cron.hourly that contains a good number of scripts I must call. #!/bin/sh sleep 15 perl /scripts/create_graph.pl sleep 15 perl /scripts/create_graph_out.pl many more lines. etc. Is there a way I can sleep random length to time before executing each but background each one so master script returns promptly. Something like. sleep (random 1 - 300 seconds, perl /scripts/create_graph_out.pl) ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Help
On Thu, Sep 05, 2013 at 10:24:55AM -0500, Matt wrote: I have a script file in my cron.hourly that contains a good number of scripts I must call. #!/bin/sh sleep 15 perl /scripts/create_graph.pl sleep 15 perl /scripts/create_graph_out.pl many more lines. etc. Don't background them individually; background the whole lot #!/bin/sh ( perl /scripts/create_graph.pl perl /scripts/create_graph_out.pl etc ) Now they will run one after another and you don't need to sleep between them. -- rgds Stephen ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Help
LIMIT=10 # Or whatever sleep `expr $RANDOM % $LIMIT + 1` -Original Message- From: centos-boun...@centos.org [mailto:centos-boun...@centos.org] On Behalf Of Matt Sent: 05 September 2013 16:25 To: CentOS mailing list Subject: [CentOS] Shell Script Help I have a script file in my cron.hourly that contains a good number of scripts I must call. #!/bin/sh sleep 15 perl /scripts/create_graph.pl sleep 15 perl /scripts/create_graph_out.pl many more lines. etc. Is there a way I can sleep random length to time before executing each but background each one so master script returns promptly. Something like. sleep (random 1 - 300 seconds, perl /scripts/create_graph_out.pl) ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos __ This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com __ - No virus found in this message. Checked by AVG - www.avg.com Version: 2013.0.3392 / Virus Database: 3211/6618 - Release Date: 08/28/13 Internal Virus Database is out of date. __ This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com __ ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Help
On 09/05/2013 11:24 AM, Matt wrote: I have a script file in my cron.hourly that contains a good number of scripts I must call. #!/bin/sh sleep 15 perl /scripts/create_graph.pl sleep 15 perl /scripts/create_graph_out.pl many more lines. etc. Is there a way I can sleep random length to time before executing each but background each one so master script returns promptly. Something like. sleep (random 1 - 300 seconds, perl /scripts/create_graph_out.pl) ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos If you are trying to avoid running all these perl scripts concurrently set up the perl scripts to accept an argument, then pass each one a time delay when you call them. PerlScript-1 20 PerlScript-2 40 ... PerlScript-n n*20 The calling script will return almost immediately but the perl scripts will delay any action for the specified time. That way the time delay is fully adjustable from zero to forever. -- _ °v° /(_)\ ^ ^ Mark LaPierre Registered Linux user No #267004 https://linuxcounter.net/ ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
[CentOS] Shell Script: Simple array usage = bad substitution?
Hey Guys n Gals; I have some arrays that I can't seem to expand correctly (if that's the correct word?), imagine the following example: #!/bin/bash myArray=(First Second Third) First=(Monday Tuesdays Wednesday) Second=(One Two Three) Third=(A B C) for ((i=0;i${#myarr...@]};i++)) do for ((k=0;k${#${myarray[$i...@]};k++)) # Things go bad here! do echo ${${myArray[$i]}[$k]} # I understand this line is won't work but it doesn't matter right now done done So ultimatly we shall loop round each value in the myArray array and print out the values in each array which has the same name as the value in the myArray, array. Where I have marked with a comment, the script stops with the error- : bad substitution I have looked on-line but I don't quite understand how I can correct this? I have seen other people have this error for other problems but not one like mine so I don't fully understand it? Can anyone explain to me exactly what is going wrong and how I might correct it? James ;) -BEGIN GEEK CODE BLOCK- Version: 3.1 GIT/MU/U dpu s: a-- C++$ U+ L++ B- P+ E? W+++$ N K W++ O M++$ V- PS+++ PE++ Y+ PGP t 5 X+ R- tv+ b+ DI D+++ G+ e(+) h--(++) r++ z++ --END GEEK CODE BLOCK-- ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script: Simple array usage = bad substitution?
On Fri, Jun 19, 2009 at 8:43 AM, James Bensley jwbens...@gmail.com wrote: Hey Guys n Gals; I have some arrays that I can't seem to expand correctly (if that's the correct word?), imagine the following example: #!/bin/bash myArray=(First Second Third) First=(Monday Tuesdays Wednesday) Second=(One Two Three) Third=(A B C) for ((i=0;i${#myarr...@]};i++)) do for ((k=0;k${#${myarray[$i...@]};k++)) # Things go bad here! do echo ${${myArray[$i]}[$k]} # I understand this line is won't work but it doesn't matter right now done done So ultimatly we shall loop round each value in the myArray array and print out the values in each array which has the same name as the value in the myArray, array. Where I have marked with a comment, the script stops with the error- : bad substitution I have looked on-line but I don't quite understand how I can correct this? I have seen other people have this error for other problems but not one like mine so I don't fully understand it? Can anyone explain to me exactly what is going wrong and how I might correct it? How about this? Avoids the c=like for loop increments and just uses the array elements for the next loop ... #!/bin/bash myArray=(First Second Third) First=(Monday Tuesdays Wednesday) Second=(One Two Three) Third=(A B C) for i in ${myarr...@]}; do for k in ${i}; do eval tmp=\${...@]} echo ${TMP} done done -Bob ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Pointers?
On Thu, May 14, 2009 at 1:31 AM, James Bensley jwbens...@gmail.com wrote: if you're already going to the effort of downloading the entire blacklist every night, why not dump the old database, and just insert the newly downloaded one? Because we also add our own entries to the current blacklist so we are just adding any new entries from the nightly updates of our blacklist provides tar -cxf blacklist.tar this will suck your computer into a vortex of doom. I recommend either creating a tarball, or extracting one, but not both at the same time. :) Its ok the blacklist is text so its a 10mb tarball of text. Takes about 30 seconds to download and it will take about 2 minutes for the script to run ;) In all honesty, you might be better targeting this query to squidGuard users, as this may be something they do regularly. Should be simple text manipulation :( none the less a good idea I will post my question there. Thanks! -BEGIN GEEK CODE BLOCK- Version: 3.1 GIT/MU/U dpu s: a-- C++$ U+ L++ B- P+ E? W+++$ N K W++ O M++$ V- PS+++ PE++ Y+ PGP t 5 X+ R- tv+ b+ DI D+++ G+ e(+) h--(++) r++ z++ --END GEEK CODE BLOCK-- ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos Why have you custom black list separate? Then when doing updates, remove the current list, concatenate the update with the custom and then put that in place. This would presumably make it easier for you to manage your custom stuff, but still be up to date. Also you could try for FOLDER in `find /usr/local/squidGuard/db -maxdepth 1 -type d`; do instead of find /usr/local/squidGuard/db -maxdepth 1 -type d | while read FOLDER; do -- Eric ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Pointers?
On Tue, 2009-05-19 at 22:06 -0400, Eric Sisolak wrote: Also you could try for FOLDER in `find /usr/local/squidGuard/db -maxdepth 1 -type d`; do This is a classic mistake. It has two problems: 1) The list of files created by the embedded find can exceed the maximum command length. 2) Directories with spaces in their name will be split by the tokenizer, resulting in $FOLDER containing invalid or dangerous paths. instead of find /usr/local/squidGuard/db -maxdepth 1 -type d | while read FOLDER; do This is the correct way to combine a shell loop with a program that creates a list of files. ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Pointers?
I have written my script but I wanted to add this on before and after the update to see the difference but all it returns are zeros? Anyone have any idea why? #!/bin/sh f=0 #Folder count d=0 #Domains count (one per line in each file) u=0 #Url count (one per line in each file) t=0 #Total of domains and urls x=0 #Temporary variable for calculations find /usr/local/squidGuard/db -maxdepth 1 -type d | while read FOLDER; do f=`expr $f + 1` if [ -f $FOLDER/domains ]; then x=`wc -l $FOLDER/domains | awk '{print $1}'` d=`expr $d + 1` fi if [ -f $FOLDER/urls ]; then x=`wc -l $FOLDER/urls | awk '{print $1}'` u=`expr $u + 1` fi done t=`expr $d + $u` echo Number of categories: $f echo Number of domains: $d echo Number of URLs: $u echo Total entries: $t echo $x This is the ouput: [ha...@hades ~]$ sh tester Number of categories: 0 Number of domains: 0 Number of URLs: 0 Total entries: 0 0 [ha...@hades ~]$ Many thanks, James ;) -BEGIN GEEK CODE BLOCK- Version: 3.1 GIT/MU/U dpu s: a-- C++$ U+ L++ B- P+ E? W+++$ N K W++ O M++$ V- PS+++ PE++ Y+ PGP t 5 X+ R- tv+ b+ DI D+++ G+ e(+) h--(++) r++ z++ --END GEEK CODE BLOCK-- ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Pointers?
Update: these lines should be: + $X d=`expr $d + 1` and snip u=`expr $u + 1` fi done James ;) -BEGIN GEEK CODE BLOCK- Version: 3.1 GIT/MU/U dpu s: a-- C++$ U+ L++ B- P+ E? W+++$ N K W++ O M++$ V- PS+++ PE++ Y+ PGP t 5 X+ R- tv+ b+ DI D+++ G+ e(+) h--(++) r++ z++ --END GEEK CODE BLOCK-- ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Pointers?
On Thu, 14 May 2009 12:35:13 +0100 James Bensley jwbens...@gmail.com wrote: Update: these lines should be: + $X that should be lower case. My guess is that because your variables all equal zero, it's possible that something is wrong with: find /usr/local/squidGuard/db -maxdepth 1 -type d | while read FOLDER; stick set -x under your #!/bin/sh to see what's running and what's not. signature.asc Description: PGP signature ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Pointers?
On Fri, May 15, 2009 at 10:17:21AM +1200, Spiro Harvey wrote: My guess is that because your variables all equal zero, it's possible that something is wrong with: find /usr/local/squidGuard/db -maxdepth 1 -type d | while read FOLDER; More likely he's using a shell that runs the while loop in a subshell. What is a=bad echo good | read a echo a is a For ksh88, ksh93, zsh it's good; for pdksh, bash it's bad. -- rgds Stephen ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
[CentOS] Shell Script Pointers?
Hey Listee's I am trying to write a shell script to sort and compare my blacklist for squidGuard with the nightly updates that come down in a tar ball. It should be rather simple but I'm not to grate at this. The script is to run nightly, it will download the latest blacklist tarball, un tar it and then add any new entries to the existing black list. The blacklists work by having a folder for each filtered category so the folder db contains the subfolders adult, gambling, drugs etc and each sub folder has two files, domains and urls (pretty self explanitory). This is how far I have gotten (I haven't tested this script yet as I haven't had a chance I have only gotten as far as writting it, this is what I have so far: #!/bin/bash #This will be running from home directory wget http://www.blacklistsite.com/blacklist.tar tar -cxf blacklist.tar cd BL find ./ -type d -maxdepth 1 | while read FOLDER; do SQUIDDB=usr/local/squidGuard/db/$FOLDER sort_db($SQUIDDB) comm -3 $SQUIDDB/domains $FOLDER/domains $SQUIDDB/domains.missing comm -3 $SQUIDDB/urls $FOLDER/urls $SQUIDDB/urls.missing cat $SQUIDDB/domains.missing $SQUIDDB/domains cat $SQUIDDB/urls.missing $SQUIDDB/urls rm $SQUIDDB/domains.missing rm $SQUIDDB/urls.missing sort_db($SQUIDDB) done sort_db(){ sort -f $1/domains $1/domains.sorted sort -f $1/urls $1/urls.sorted rm $1/domains rm $1/urls mv $1/doamins.sorted $1/domains mv $1/urls.sorted $1/urls } Is it obvious I'm new to this? Hehe, I would also love to hear how people would do this in a more efficient manner because obvisouly this is pretty sloppy and as I said I haven't tested it yet so it might not even run?! Thanks, James ;) -BEGIN GEEK CODE BLOCK- Version: 3.1 GIT/MU/U dpu s: a-- C++$ U+ L++ B- P+ E? W+++$ N K W++ O M++$ V- PS+++ PE++ Y+ PGP t 5 X+ R- tv+ b+ DI D+++ G+ e(+) h--(++) r++ z++ --END GEEK CODE BLOCK-- ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Pointers?
to run nightly, it will download the latest blacklist tarball, un tar it and then add any new entries to the existing black list. The if you're already going to the effort of downloading the entire blacklist every night, why not dump the old database, and just insert the newly downloaded one? tar -cxf blacklist.tar this will suck your computer into a vortex of doom. I recommend either creating a tarball, or extracting one, but not both at the same time. :) In all honesty, you might be better targeting this query to squidGuard users, as this may be something they do regularly. signature.asc Description: PGP signature ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Pointers?
if you're already going to the effort of downloading the entire blacklist every night, why not dump the old database, and just insert the newly downloaded one? Because we also add our own entries to the current blacklist so we are just adding any new entries from the nightly updates of our blacklist provides tar -cxf blacklist.tar this will suck your computer into a vortex of doom. I recommend either creating a tarball, or extracting one, but not both at the same time. :) Its ok the blacklist is text so its a 10mb tarball of text. Takes about 30 seconds to download and it will take about 2 minutes for the script to run ;) In all honesty, you might be better targeting this query to squidGuard users, as this may be something they do regularly. Should be simple text manipulation :( none the less a good idea I will post my question there. Thanks! -BEGIN GEEK CODE BLOCK- Version: 3.1 GIT/MU/U dpu s: a-- C++$ U+ L++ B- P+ E? W+++$ N K W++ O M++$ V- PS+++ PE++ Y+ PGP t 5 X+ R- tv+ b+ DI D+++ G+ e(+) h--(++) r++ z++ --END GEEK CODE BLOCK-- ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
[CentOS] shell script
I have to run multiple command about 20x on linux each one got his own output, I want to bind all the out puts of them in one file then read this file and mail it to user account sample [r...@imail pons]# /home/pons/tsmmonitor stgpool SDC-STAFF stgpool - utilization of storage pool SDC-STAFF 62%, OK [r...@imail pons]# /home/pons/tsmmonitor stgpool ISO-BACKUP-POOL stgpool - utilization of storage pool ISO-BACKUP-POOL 41%, OK [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK I want all these out puts be bind it in one file myfile: stgpool - utilization of storage pool SDC-STAFF 62%, OK stgpool - utilization of storage pool ISO-BACKUP-POOL 41%, OK stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK then to read this file and send it to email address Thanks ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script
Hi Mad Unix, On Sun, Feb 8, 2009 at 09:06, Mad Unix madu...@gmail.com wrote: I have to run multiple command about 20x on linux each one got his own output, It is not the first time you come to the list with questions about shell scripting, and most of them very basic. So, what I really recommend for you now is this: http://letmegooglethatforyou.com/?q=learn+shell+script I want to bind all the out puts of them in one file Read my previous post about using redirection more efficiently: http://lists.centos.org/pipermail/centos/2009-February/071813.html then read this file and mail it to user account man mail You will only learn if you try. If you really try and it still does not work as you expect, and you have more specific questions, please post them to the list. When you do, please use more specific subjects. HTH, Filipe ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script
resolved. On Sun, Feb 8, 2009 at 4:33 PM, Filipe Brandenburger filbran...@gmail.com wrote: Hi Mad Unix, On Sun, Feb 8, 2009 at 09:06, Mad Unix madu...@gmail.com wrote: I have to run multiple command about 20x on linux each one got his own output, It is not the first time you come to the list with questions about shell scripting, and most of them very basic. So, what I really recommend for you now is this: http://letmegooglethatforyou.com/?q=learn+shell+script I want to bind all the out puts of them in one file Read my previous post about using redirection more efficiently: http://lists.centos.org/pipermail/centos/2009-February/071813.html then read this file and mail it to user account man mail You will only learn if you try. If you really try and it still does not work as you expect, and you have more specific questions, please post them to the list. When you do, please use more specific subjects. HTH, Filipe ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos -- UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity. Dennis Ritchie. ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script
Mad Unix wrote: I have to run multiple command about 20x on linux each one got his own output, I want to bind all the out puts of them in one file then read this file and mail it to user account sample [r...@imail pons]# /home/pons/tsmmonitor stgpool SDC-STAFF stgpool - utilization of storage pool SDC-STAFF 62%, OK [r...@imail pons]# /home/pons/tsmmonitor stgpool ISO-BACKUP-POOL stgpool - utilization of storage pool ISO-BACKUP-POOL 41%, OK [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK I want all these out puts be bind it in one file myfile: stgpool - utilization of storage pool SDC-STAFF 62%, OK stgpool - utilization of storage pool ISO-BACKUP-POOL 41%, OK stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK then to read this file and send it to email address Thanks ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos Hi, Do this by re-directing the output from your commands into a file like this: [r...@imail pons]# /home/pons/tsmmonitor stgpool SDC-STAFF outfile [r...@imail pons]# /home/pons/tsmmonitor stgpool ISO-BACKUP-POOL outfile [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL outfile [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL outfile Note that the single in the first line will create a new outfile that is it will create the file if it does not exist or over-write it if it does exist. The double in the following commands will append the output of those commands to the already existing outfile. ChrisG ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script
On Sun, Feb 8, 2009 at 9:52 AM, Chris Geldenhuis chris.gel...@iafrica.comwrote: Mad Unix wrote: I have to run multiple command about 20x on linux each one got his own output, I want to bind all the out puts of them in one file then read this file and mail it to user account sample [r...@imail pons]# /home/pons/tsmmonitor stgpool SDC-STAFF stgpool - utilization of storage pool SDC-STAFF 62%, OK [r...@imail pons]# /home/pons/tsmmonitor stgpool ISO-BACKUP-POOL stgpool - utilization of storage pool ISO-BACKUP-POOL 41%, OK [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK I want all these out puts be bind it in one file myfile: stgpool - utilization of storage pool SDC-STAFF 62%, OK stgpool - utilization of storage pool ISO-BACKUP-POOL 41%, OK stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK then to read this file and send it to email address Thanks ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos Hi, Do this by re-directing the output from your commands into a file like this: [r...@imail pons]# /home/pons/tsmmonitor stgpool SDC-STAFF outfile [r...@imail pons]# /home/pons/tsmmonitor stgpool ISO-BACKUP-POOL outfile [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL outfile [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL outfile Note that the single in the first line will create a new outfile that is it will create the file if it does not exist or over-write it if it does exist. The double in the following commands will append the output of those commands to the already existing outfile. ChrisG Actually will also create the file if it doesn't exit. Try it :) -matt http://www.sysadminvalley.com http://www.beantownhost.com http://www.linkedin.com/in/mattboston Joe E. Lewis - I distrust camels, and anyone else who can go a week without a drink. ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script
Matt Shields wrote: On Sun, Feb 8, 2009 at 9:52 AM, Chris Geldenhuis chris.gel...@iafrica.com mailto:chris.gel...@iafrica.com wrote: Mad Unix wrote: I have to run multiple command about 20x on linux each one got his own output, I want to bind all the out puts of them in one file then read this file and mail it to user account sample [r...@imail pons]# /home/pons/tsmmonitor stgpool SDC-STAFF stgpool - utilization of storage pool SDC-STAFF 62%, OK [r...@imail pons]# /home/pons/tsmmonitor stgpool ISO-BACKUP-POOL stgpool - utilization of storage pool ISO-BACKUP-POOL 41%, OK [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK I want all these out puts be bind it in one file myfile: stgpool - utilization of storage pool SDC-STAFF 62%, OK stgpool - utilization of storage pool ISO-BACKUP-POOL 41%, OK stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK then to read this file and send it to email address Thanks ___ CentOS mailing list CentOS@centos.org mailto:CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos Hi, Do this by re-directing the output from your commands into a file like this: [r...@imail pons]# /home/pons/tsmmonitor stgpool SDC-STAFF outfile [r...@imail pons]# /home/pons/tsmmonitor stgpool ISO-BACKUP-POOL outfile [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL outfile [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL outfile Note that the single in the first line will create a new outfile that is it will create the file if it does not exist or over-write it if it does exist. The double in the following commands will append the output of those commands to the already existing outfile. ChrisG Actually will also create the file if it doesn't exit. Try it :) -matt http://www.sysadminvalley.com http://www.beantownhost.com http://www.linkedin.com/in/mattboston Joe E. Lewis - I distrust camels, and anyone else who can go a week without a drink. ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos Hi Matt, I know that, but if you use and there is some file there with that name already the data will be appended to it instead of starting a new file with the output of your current session only. ChrisG ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script
You want this and I want a grapefruit. Thanks for you attitude. Kai -- Kai Schätzl, Berlin, Germany Get your web at Conactive Internet Services: http://www.conactive.com ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script
On Sun, Feb 8, 2009 at 10:02 AM, Chris Geldenhuis chris.gel...@iafrica.comwrote: Matt Shields wrote: On Sun, Feb 8, 2009 at 9:52 AM, Chris Geldenhuis chris.gel...@iafrica.com mailto:chris.gel...@iafrica.com wrote: Mad Unix wrote: I have to run multiple command about 20x on linux each one got his own output, I want to bind all the out puts of them in one file then read this file and mail it to user account sample [r...@imail pons]# /home/pons/tsmmonitor stgpool SDC-STAFF stgpool - utilization of storage pool SDC-STAFF 62%, OK [r...@imail pons]# /home/pons/tsmmonitor stgpool ISO-BACKUP-POOL stgpool - utilization of storage pool ISO-BACKUP-POOL 41%, OK [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK I want all these out puts be bind it in one file myfile: stgpool - utilization of storage pool SDC-STAFF 62%, OK stgpool - utilization of storage pool ISO-BACKUP-POOL 41%, OK stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK stgpool - utilization of storage pool ORACLE-DUMP-POOL 62%, OK then to read this file and send it to email address Thanks ___ CentOS mailing list CentOS@centos.org mailto:CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos Hi, Do this by re-directing the output from your commands into a file like this: [r...@imail pons]# /home/pons/tsmmonitor stgpool SDC-STAFF outfile [r...@imail pons]# /home/pons/tsmmonitor stgpool ISO-BACKUP-POOL outfile [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL outfile [r...@imail pons]# /home/pons/tsmmonitor stgpool ORACLE-DUMP-POOL outfile Note that the single in the first line will create a new outfile that is it will create the file if it does not exist or over-write it if it does exist. The double in the following commands will append the output of those commands to the already existing outfile. ChrisG Actually will also create the file if it doesn't exit. Try it :) -matt http://www.sysadminvalley.com http://www.beantownhost.com http://www.linkedin.com/in/mattboston Joe E. Lewis - I distrust camels, and anyone else who can go a week without a drink. ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos Hi Matt, I know that, but if you use and there is some file there with that name already the data will be appended to it instead of starting a new file with the output of your current session only. ChrisG For some that might be what they want. :) -matt http://www.sysadminvalley.com http://www.beantownhost.com http://www.linkedin.com/in/mattboston Charles M. Schulz - I love mankind; it's people I can't stand. ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
[CentOS] Shell Script - Compare packages. rpm.
Hi, I need a script which makes the package compação rpm's through two text files ... Since a file is the output of the command *rpm-qa pkg.out * And the second file is a list of several packages rpm's, multiple versions and architectures. My idea is to compare a package *x* file pkg.out with several packages *y* of the file update.out and know whether a package and has a larger version of the package *x* installed and with that I return I have a package to be updated. Does anyone can help me do this comparison? OBS.: The servers do not have access to internet. Here's an example of the packages described in the files: [r...@rpm tiago]# tail -n12 pkg.out glibc-devel-2.3.4-2.39 libuser-devel-0.52.5-1.el4.1 libmudflap-4.1.2-14.EL4 iiimf-libs-devel-12.1-13.EL.6 xorg-x11-devel-6.8.2-1.EL.33 lam-libs-7.1.2-8 libdbi-0.6.5-10.RHEL4.1 unixODBC-kde-2.2.11-1.RHEL4.1 perl-Compress-Zlib-1.42-1.el4 MySQL-python-1.2.1_p2-1.el4.1 nmap-3.70-1 sysstat-5.0.5-16.rhel4 [r...@rpm tiago]# -- [r...@rpm tiago]# cat update.out glibc-devel-2.3.4-2.41.i386.rpm glibc-devel-2.3.4-2.39.i386.rpm glibc-devel-2.3.4-2.36.i386.rpm glibc-devel-2.3.4-2.25.i386.rpm glibc-devel-2.3.4-2.19.i386.rpm glibc-devel-2.3.4-2.13.i386.rpm glibc-devel-2.3.4-2.9.i386.rpm glibc-devel-2.3.4-2.i386.rpm libuser-devel-0.52.5-1.el4.3.i386.rpm libuser-devel-0.52.5-1.el4.1.i386.rpm libuser-devel-0.52.5-1.i386.rpm libmudflap-4.1.2-42.EL4.i386.rpm libmudflap-4.1.2-14.EL4.i386.rpm libmudflap-4.1.1-53.EL4.i386.rpm libmudflap-4.1.0-18.EL4.3.i386.rpm libmudflap-4.1.0-18.EL4.i386.rpm libmudflap-4.0.2-14.EL4.i386.rpm libmudflap-4.0.1-4.EL4.2.i386.rpm libmudflap-4.0.0-0.14.EL4.i386.rpm xorg-x11-devel-6.8.2-1.EL.52.i386.rpm xorg-x11-devel-6.8.2-1.EL.33.0.4.i386.rpm xorg-x11-devel-6.8.2-1.EL.33.0.2.i386.rpm xorg-x11-devel-6.8.2-1.EL.33.0.1.i386.rpm xorg-x11-devel-6.8.2-1.EL.33.i386.rpm xorg-x11-devel-6.8.2-1.EL.31.i386.rpm xorg-x11-devel-6.8.2-1.EL.19.i386.rpm xorg-x11-devel-6.8.2-1.EL.18.i386.rpm xorg-x11-devel-6.8.2-1.EL.13.37.7.i386.rpm xorg-x11-devel-6.8.2-1.EL.13.37.5.i386.rpm xorg-x11-devel-6.8.2-1.EL.13.37.2.i386.rpm xorg-x11-devel-6.8.2-1.EL.13.37.i386.rpm xorg-x11-devel-6.8.2-1.EL.13.36.i386.rpm xorg-x11-devel-6.8.2-1.EL.13.25.1.i386.rpm xorg-x11-devel-6.8.2-1.EL.13.25.i386.rpm xorg-x11-devel-6.8.2-1.EL.13.20.i386.rpm xorg-x11-devel-6.8.2-1.EL.13.16.i386.rpm xorg-x11-devel-6.8.2-1.EL.13.6.i386.rpm xorg-x11-devel-6.8.1-23.EL.i386.rpm lam-libs-7.1.2-15.el4:2.i386.rpm lam-libs-7.1.2-8:2.i386.rpm MySQL-python-1.2.1_p2-1.el4.1.i386.rpm MySQL-python-1.0.0-1.RHEL4.1.i386.rpm sysstat-5.0.5-19.el4.i386.rpm sysstat-5.0.5-16.rhel4.i386.rpm sysstat-5.0.5-15.0.1.el4.i386.rpm sysstat-5.0.5-14.rhel4.i386.rpm sysstat-5.0.5-11.rhel4.i386.rpm sysstat-5.0.5-7.rhel4.i386.rpm sysstat-5.0.5-1.i386.rpm nmap-3.70-1:2.i386.rpm [r...@rpm tiago]# Att, -- Tiago Dias da Silva Administrador de Sistemas GNU/Linux HomePage: www.dias.eti.br Email: ti...@dias.eti.br A mente que se abre a uma nova idéia jamais voltará ao seu tamanho original (Albert Einstein) ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script - Compare packages. rpm.
On Mon, 2009-01-26 at 08:26 -0200, Tiago Dias wrote: Hi, I need a script which makes the package compação rpm's through two text files ... Since a file is the output of the command rpm-qa pkg.out And the second file is a list of several packages rpm's, multiple versions and architectures. My idea is to compare a package x file pkg.out with several packages y of the file update.out and know whether a package and has a larger version of the package x installed and with that I return I have a package to be updated. Does anyone can help me do this comparison? Looks like you want to see what the update packages are without doing the updates, and without an internet connection. About 5 years ago I would have suggest running 'rpm --freshen --test packagename-from-update.out'. Today, I'd suggest saving even more time and just a local instance of mrepo. Configure your yum repos in /etc/yum.repos.d/ to point to the repository, and install the yum-updatesd package to find out what the new packages are... Why reinvent the wheel? ;) -I ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script - Compare packages. rpm.
From: Tiago Dias tux.ti...@gmail.com I need a script which makes the package compação rpm's through two text files ... Since a file is the output of the command rpm-qa pkg.out And the second file is a list of several packages rpm's, multiple versions and architectures. Just for the fun (and did not really test it): cat pkg.out | awk ' { p=$1; n=match(p, -[[:digit:]]+); print substr(p,1,n); } '| while read PKG; dogrep $PKG[0-9] update.out; done I will leave you as an exercise to sort the results by versions and head (or tail) to keep the highest one... ^_^ But, if your update.out file contained only the latest package (and not all different versions), that should work. JD ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script to list group members
Bob Beers wrote: grep group_name: /etc/group | cut -d: -f4 will give a comma separated list, provided group_name is a valid group name. There is one problem with this approach, which is the assumption that all users' primary group is the same as their login id - which I agree is typically the RHEL way, but it doesn't have to be the case. If however you have users with their primary group set to something other than the login id - e.g. admin or marketing - then you need to look in the /etc/passwd file as well because these users don't appear in the comma separated list outlined above. To check the /etc/passwd file, you have to determine the group id value, and then scan the /etc/passwd file looking for that value in column 4. This will give you a list of users whose primary group is the group value you're interested in. Cheers, Ian smime.p7s Description: S/MIME Cryptographic Signature ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script to list group members
Part 1: On Tue, Sep 23, 2008 at 7:37 PM, Ian Blackwell [EMAIL PROTECTED] wrote: Bob Beers wrote: grep group_name: /etc/group | cut -d: -f4 will give a comma separated list, provided group_name is a valid group name. There is one problem with this approach, which is the assumption that all users' primary group is the same as their login id - which I agree is typically the RHEL way, but it doesn't have to be the case. If however you have users with their primary group set to something other than the login id - e.g. admin or marketing - then you need to look in the /etc/passwd file as well because these users don't appear in the comma separated list outlined above. To check the /etc/passwd file, you have to determine the group id value, and then scan the /etc/passwd file looking for that value in column 4. This will give you a list of users whose primary group is the group value you're interested in. You have a valid point, but the OP's question was: I am looking for a (simple) shell command to run from a bash script that will allow me to list user accounts that belong to a particular group. Part 2: On Tue, Sep 23, 2008 at 6:43 PM, Barry Brimer [EMAIL PROTECTED] wrote: The egrep is using a leading anchor (^) to make sure the grep matches the beginning of the line. If not, and the group pattern matched as one of the users it would print those lines too .. which is probably undesirable. My instinct is that by specifying the groupname as an argument as in: 'getent group groupname', ( rather than asking for all groups with 'getent group', and then (e)grep'ing, ) that the result would not match for users in the groups list. But I may be wrong. I have not looked at the source code. But I tested on my system and I did not see the behavior you warn of. If I am correct about the getent program, then there is also the added benefit of avoiding the pipe. :-) -Bob ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script to list group members
Bob Beers wrote: Part 1: You have a valid point, but the OP's question was: I am looking for a (simple) shell command to run from a bash script that will allow me to list user accounts that belong to a particular group. In all likelihood the system follows the default approach of setting the primary group to be the user's personal ground. If that is the case then you're correct in providing a simple solution as requested. I just wanted to make Tim aware that if his user's have primary groups other than their personal groups - e.g. admin or marketing - then there isn't a simple answer (not that the answer is all that hard). Here's a script I knocked up to do it - although there can be duplication and output formatting isn't perfect:- #!/bin/bash #set -x # $1 is the group to test if [ $1 = ]; then echo Which group? exit 1 fi groupid=$(getent group $1 | cut -d: -f3) grouplst=$(getent group $1 | cut -d: -f4) for User in $(cat /etc/passwd | cut -f1 -d:) do if [ $(id -g $User) = $groupid ]; then grouplst=$(echo $grouplst),$User fi done echo Members of group $1 are: $grouplst exit 0 Regards, Ian smime.p7s Description: S/MIME Cryptographic Signature ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
[CentOS] Shell script to list group members
I have several shell scripts to manage user accounts on a server. I've been using a file with the usernames of peoples accounts that any script needs to process. I had a thought that I can and should be setting up groups and adding user accounts to those groups so I don't have to maintain a set of files with the user accounts. So essentially, I am looking for a (simple) shell command to run from a bash script that will allow me to list user accounts that belong to a particular group. Any help is appreciated. begin:vcard fn:Tim Alberts n:Alberts;Tim org:Measurement Systems International;Engineering adr:Suite 200;;14240 Interurban Avenue South;Seattle;WA;98168;USA email;internet:[EMAIL PROTECTED] title:Associate Engineer tel;work:206-433-0199 tel;fax:206-244-8470 x-mozilla-html:FALSE url:http://www.msiscales.com/ version:2.1 end:vcard ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script to list group members
Quoting Tim Alberts [EMAIL PROTECTED]: I have several shell scripts to manage user accounts on a server. I've been using a file with the usernames of peoples accounts that any script needs to process. I had a thought that I can and should be setting up groups and adding user accounts to those groups so I don't have to maintain a set of files with the user accounts. So essentially, I am looking for a (simple) shell command to run from a bash script that will allow me to list user accounts that belong to a particular group. Any help is appreciated. With spaces separating groups: egrep -e '^groupname:' /etc/group | awk -F : '{ print $4 }' | sed -e 's/,/ /g' With commas separating groups: egrep -e '^groupname:' /etc/group | awk -F : '{ print $4 }' ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script to list group members
On Tue, Sep 23, 2008 at 1:31 PM, Tim Alberts [EMAIL PROTECTED] wrote: So essentially, I am looking for a (simple) shell command to run from a bash script that will allow me to list user accounts that belong to a particular group. Any help is appreciated. grep group_name: /etc/group | cut -d: -f4 will give a comma separated list, provided group_name is a valid group name. HTH, -Bob ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script to list group members
Barry Brimer wrote: With spaces separating groups: egrep -e '^groupname:' /etc/group | awk -F : '{ print $4 }' | sed -e 's/,/ /g' With commas separating groups: egrep -e '^groupname:' /etc/group | awk -F : '{ print $4 }' I'm sorry, I didn't specify, I'm using LDAP for user/group management. Ideally a command like 'groups' would be nice, except it would be the inverse, it would print the users in a group, not the groups a user belongs to. begin:vcard fn:Tim Alberts n:Alberts;Tim org:Measurement Systems International;Engineering adr:Suite 200;;14240 Interurban Avenue South;Seattle;WA;98168;USA email;internet:[EMAIL PROTECTED] title:Associate Engineer tel;work:206-433-0199 tel;fax:206-244-8470 x-mozilla-html:FALSE url:http://www.msiscales.com/ version:2.1 end:vcard ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script to list group members
On Tue, Sep 23, 2008 at 7:11 PM, Tim Alberts [EMAIL PROTECTED] wrote: Barry Brimer wrote: With spaces separating groups: egrep -e '^groupname:' /etc/group | awk -F : '{ print $4 }' | sed -e 's/,/ /g' With commas separating groups: egrep -e '^groupname:' /etc/group | awk -F : '{ print $4 }' I'm sorry, I didn't specify, I'm using LDAP for user/group management. Ideally a command like 'groups' would be nice, except it would be the inverse, it would print the users in a group, not the groups a user belongs to. I guess ... ldapsearch ... (group=xyz) ... HTH, -Bob ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script to list group members
Quoting Tim Alberts [EMAIL PROTECTED]: Barry Brimer wrote: With spaces separating groups: egrep -e '^groupname:' /etc/group | awk -F : '{ print $4 }' | sed -e 's/,/ /g' With commas separating groups: egrep -e '^groupname:' /etc/group | awk -F : '{ print $4 }' I'm sorry, I didn't specify, I'm using LDAP for user/group management. Ideally a command like 'groups' would be nice, except it would be the inverse, it would print the users in a group, not the groups a user belongs to. With commas separating groups: getent group | egrep -i '^groupname:' | awk -F : '{ print $4}' With spaces separating groups: getent group | egrep -i '^groupname:' | awk -F : '{ print $4}' | sed -e 's/,/ /g' ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script to list group members
On Tue, Sep 23, 2008 at 7:26 PM, Barry Brimer [EMAIL PROTECTED] wrote: Quoting Tim Alberts [EMAIL PROTECTED]: Barry Brimer wrote: With spaces separating groups: egrep -e '^groupname:' /etc/group | awk -F : '{ print $4 }' | sed -e 's/,/ /g' With commas separating groups: egrep -e '^groupname:' /etc/group | awk -F : '{ print $4 }' I'm sorry, I didn't specify, I'm using LDAP for user/group management. Ideally a command like 'groups' would be nice, except it would be the inverse, it would print the users in a group, not the groups a user belongs to. With commas separating groups: getent group | egrep -i '^groupname:' | awk -F : '{ print $4}' With spaces separating groups: getent group | egrep -i '^groupname:' | awk -F : '{ print $4}' | sed -e 's/,/ /g' ok, Barry wins. :) But, I don't think you need the egrep ... getent group groupname | ... works ok for me. -Bob ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script to list group members
Bob Beers wrote: On Tue, Sep 23, 2008 at 7:26 PM, Barry Brimer [EMAIL PROTECTED] wrote: With commas separating groups: getent group | egrep -i '^groupname:' | awk -F : '{ print $4}' With spaces separating groups: getent group | egrep -i '^groupname:' | awk -F : '{ print $4}' | sed -e 's/,/ /g' ok, Barry wins. :) But, I don't think you need the egrep ... getent group groupname | ... works ok for me. -Bob Excellent, 'getent group...' should do perfectly. Thanks Barry and Bob. begin:vcard fn:Tim Alberts n:Alberts;Tim org:Measurement Systems International;Engineering adr:Suite 200;;14240 Interurban Avenue South;Seattle;WA;98168;USA email;internet:[EMAIL PROTECTED] title:Associate Engineer tel;work:206-433-0199 tel;fax:206-244-8470 x-mozilla-html:FALSE url:http://www.msiscales.com/ version:2.1 end:vcard ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script to list group members
On Tue, 23 Sep 2008, Bob Beers wrote: On Tue, Sep 23, 2008 at 7:26 PM, Barry Brimer [EMAIL PROTECTED] wrote: Quoting Tim Alberts [EMAIL PROTECTED]: Barry Brimer wrote: With spaces separating groups: egrep -e '^groupname:' /etc/group | awk -F : '{ print $4 }' | sed -e 's/,/ /g' With commas separating groups: egrep -e '^groupname:' /etc/group | awk -F : '{ print $4 }' I'm sorry, I didn't specify, I'm using LDAP for user/group management. Ideally a command like 'groups' would be nice, except it would be the inverse, it would print the users in a group, not the groups a user belongs to. With commas separating groups: getent group | egrep -i '^groupname:' | awk -F : '{ print $4}' With spaces separating groups: getent group | egrep -i '^groupname:' | awk -F : '{ print $4}' | sed -e 's/,/ /g' ok, Barry wins. :) But, I don't think you need the egrep ... getent group groupname | ... works ok for me. The egrep is using a leading anchor (^) to make sure the grep matches the beginning of the line. If not, and the group pattern matched as one of the users it would print those lines too .. which is probably undesirable. Barry ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script to list group members
On Tue, Sep 23, 2008 at 6:43 PM, Barry Brimer [EMAIL PROTECTED] wrote: The egrep is using a leading anchor (^) to make sure the grep matches the beginning of the line. If not, and the group pattern matched as one of the users it would print those lines too .. which is probably undesirable. Grep understands the '^', so egrep is not needed. Typically, you only need egrep for patterns that involve alternative re's, like looking for one of abc|def|ghi which grep does not recognize. Also, it might be helpful to trim your replies so we don't need to wade through the whole thread to see your reply. mhr ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
[CentOS] Shell script - ping
hi, how to write a scripts which launches 10 pings to different destinations at execution of single shell scripts please help me any ideas regards, Gopinath ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script - ping
Gopinath Achari wrote: hi, how to write a scripts which launches 10 pings to different destinations at execution of single shell scripts please help me any ideas regards, Gopinath Do you mean something like: ping -c10 host1 ping -c10 host2 which will ping host1 10 times, then host2 10 times etc. (see `man ping` for details of the options). If you have a list of hosts in a file, you could do: for host in `cat [filename]` do ping -c10 $host done or: while read host do ping -c10 $host done [filename] If you only want to ping each host once, you can substitute '-c10' with '-c1' (again, see the man page). Hope this helps Laurence ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script - ping
Hi, If you you want a quicker execution - you could also run the pings to separate hosts in parallel starting the jobs in background () and waiting for them with wait after that. You'll have to be more careful about the outputs in that case - e.g. redirect them to separate files. Regards, Javor On Mon, Jul 28, 2008 at 2:57 PM, Laurence Alexander Hurst [EMAIL PROTECTED] wrote: Gopinath Achari wrote: hi, how to write a scripts which launches 10 pings to different destinations at execution of single shell scripts please help me any ideas regards, Gopinath Do you mean something like: ping -c10 host1 ping -c10 host2 which will ping host1 10 times, then host2 10 times etc. (see `man ping` for details of the options). If you have a list of hosts in a file, you could do: for host in `cat [filename]` do ping -c10 $host done or: while read host do ping -c10 $host done [filename] If you only want to ping each host once, you can substitute '-c10' with '-c1' (again, see the man page). Hope this helps Laurence ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script - ping
On Mon, Jul 28, 2008, Gopinath Achari wrote: hi, how to write a scripts which launches 10 pings to different destinations at execution of single shell scripts please help me any ideas If your goal is to test connectivity, you might look at the perl Net::Ping module. ``perldoc Net::Ping'' has several examples of checking one or more systems to see if they are alive. BTW: Anybody know of a python equivalent to this? Bill -- INTERNET: [EMAIL PROTECTED] Bill Campbell; Celestial Software LLC URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way Voice: (206) 236-1676 Mercer Island, WA 98040-0820 Fax:(206) 232-9186 A tax-supported, compulsory educational system is the complete model of the totalitarian state. -- Isabel Paterson, God of the Machine ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script - ping
Bill Campbell escribió: On Mon, Jul 28, 2008, Gopinath Achari wrote: hi, how to write a scripts which launches 10 pings to different destinations at execution of single shell scripts please help me any ideas If your goal is to test connectivity, you might look at the perl Net::Ping module. ``perldoc Net::Ping'' has several examples of checking one or more systems to see if they are alive. BTW: Anybody know of a python equivalent to this? Bill Hello, I have done something before with nmap -sP target time ago. Later you can grep the response to know whether an IP address is alive or not. Hope it helps, -- Lorenzo Martínez Rodríguez Consultor de seguridad informática ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell script - ping
thank u all On Mon, 2008-07-28 at 16:11 +0300, Javor Nikolov wrote: Hi, If you you want a quicker execution - you could also run the pings to separate hosts in parallel starting the jobs in background () and waiting for them with wait after that. You'll have to be more careful about the outputs in that case - e.g. redirect them to separate files. Regards, Javor On Mon, Jul 28, 2008 at 2:57 PM, Laurence Alexander Hurst [EMAIL PROTECTED] wrote: Gopinath Achari wrote: hi, how to write a scripts which launches 10 pings to different destinations at execution of single shell scripts please help me any ideas regards, Gopinath Do you mean something like: ping -c10 host1 ping -c10 host2 which will ping host1 10 times, then host2 10 times etc. (see `man ping` for details of the options). If you have a list of hosts in a file, you could do: for host in `cat [filename]` do ping -c10 $host done or: while read host do ping -c10 $host done [filename] If you only want to ping each host once, you can substitute '-c10' with '-c1' (again, see the man page). Hope this helps Laurence ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
[CentOS] Shell Script Question
What's the simplest way to increment the number up by one until some other 4 digit number while preserving leading zero's until the 1000's has a digit other than 0? Thanks! jlc ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Question
On Wed, 9 Jul 2008, Joseph L. Casale wrote: What's the simplest way to increment the number up by one until some other 4 digit number while preserving leading zero's until the 1000's has a digit other than 0? In zsh, it would be something like: for i in {..}; do echo $i done -steve ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Question
On Wed, Jul 9, 2008 at 6:22 PM, Joseph L. Casale [EMAIL PROTECTED] wrote: What's the simplest way to increment the number up by one until some other 4 digit number while preserving leading zero's until the 1000's has a digit other than 0? Your homework done in a snap! for (i=0; i1000;i++); do printf %04d\n i done Thanks! jlc ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos -- Stephen J Smoogen. -- BSD/GNU/Linux How far that little candle throws his beams! So shines a good deed in a naughty world. = Shakespeare. The Merchant of Venice ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
RE: [CentOS] Shell Script Question
Your homework done in a snap! Lol, nah, not homework :P I don't know what I was thinking, long day. OTH, I never seq could do this as well! Thanks! jlc ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Question
What's the simplest way to increment the number up by one until some other 4 digit number while preserving leading zero's until the 1000's has a digit other than 0? Lots of answers, depending on the shell. I like this version for ksh: typeset -Z4 a=-1 while (( a++ 1000 )) do print $a done Not enough use is made of typeset :-) -- rgds Stephen ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Shell Script Question
Joseph L. Casale [EMAIL PROTECTED] wrote: What's the simplest way to increment the number up by one until some other 4 digit number while preserving leading zero's until the 1000's has a digit other than 0? Easy: $ seq -f %04g Best, --- Les Bell, RHCE, CISSP [http://www.lesbell.com.au] Tel: +61 2 9451 1144 FreeWorldDialup: 800909 ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script strangeness...
Craig White wrote: That works fine one CentOS 5 (double quotes and backtics) but not on CentOS 4.6 Thanks...I guess it's good enough for now. Craig ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos I can only imagine it is working in 4.6 because the result of grep entry_chooser.js /var/log/httpd/access_log is either empty or 1 word. The test syntax [ -z xxx ] would report the too many arguments error whenever the grep returned more than one word. You can test this at your command line by typing in:- [ -z one ] and [ -z one two three four five ] The first will return false but you'll just see another bash prompt, the second will report the too many arguments error. This is certainly the case for me using RHEL4.6, so I would imagine CentOS4.6 should be the same. You can also see it explained by these commands and results:- [EMAIL PROTECTED] ~]$ [ -z ] [EMAIL PROTECTED] ~]$ echo $? 0 [EMAIL PROTECTED] ~]$ [ -z one ] [EMAIL PROTECTED] ~]$ echo $? 1 [EMAIL PROTECTED] ~]$[ -z one two three four ] -bash: [: too many arguments [EMAIL PROTECTED] ~]$ echo $? 2 [EMAIL PROTECTED] ~]$ I hope this helps you understand why it is working on one machine but not another. Ian PS: I always prefer $(cmd) to backtics for readability. e.g. if [ -z $(grep entry_chooser.js /var/log/httpd/access_log) ] PPS: grep -q works for me on RHEL4.6 and CentOS5.1 ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script strangeness...
On Fri, 2008-05-16 at 17:03 +0930, Ian Blackwell wrote: Craig White wrote: That works fine one CentOS 5 (double quotes and backtics) but not on CentOS 4.6 Thanks...I guess it's good enough for now. Craig ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos I can only imagine it is working in 4.6 because the result of grep entry_chooser.js /var/log/httpd/access_log is either empty or 1 word. The test syntax [ -z xxx ] would report the too many arguments error whenever the grep returned more than one word. You can test this at your command line by typing in:- [ -z one ] and [ -z one two three four five ] The first will return false but you'll just see another bash prompt, the second will report the too many arguments error. This is certainly the case for me using RHEL4.6, so I would imagine CentOS4.6 should be the same. You can also see it explained by these commands and results:- [EMAIL PROTECTED] ~]$ [ -z ] [EMAIL PROTECTED] ~]$ echo $? 0 [EMAIL PROTECTED] ~]$ [ -z one ] [EMAIL PROTECTED] ~]$ echo $? 1 [EMAIL PROTECTED] ~]$[ -z one two three four ] -bash: [: too many arguments [EMAIL PROTECTED] ~]$ echo $? 2 [EMAIL PROTECTED] ~]$ I hope this helps you understand why it is working on one machine but not another. Ian PS: I always prefer $(cmd) to backtics for readability. e.g. if [ -z $(grep entry_chooser.js /var/log/httpd/access_log) ] PPS: grep -q works for me on RHEL4.6 and CentOS5.1 makes a lot of sense - thanks Craig ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
[CentOS] shell script strangeness...
On my CentOS 4.6 server, this works... if [ -z `grep entry_chooser.js /var/log/httpd/access_log` ] On my CentOS 5.1 server, this gives me the following error... ./test_file.scr: line 3: [: too many arguments Can anyone explain why the difference and suggest something that makes both cases happy? Thanks Craig ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script strangeness...
Craig White wrote: On my CentOS 4.6 server, this works... if [ -z `grep entry_chooser.js /var/log/httpd/access_log` ] On my CentOS 5.1 server, this gives me the following error... ./test_file.scr: line 3: [: too many arguments Can anyone explain why the difference and suggest something that makes both cases happy? Thanks Craig ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos Not sure why 4.6 is allowing it, but your if test will be resolving to something like this:- if [ -z this line from your log file and another line and even more lines until your if test fails with too many arguments I hope you don't want me to keep typing to make the point ] To fix it, wrap the grep instead double quotes as well as the ticks - e.g. if [ -z `grep entry_chooser.js /var/log/httpd/access_log` ] Then the output from the grep will be seen as one long string, not a multitude of words from your log file. Ian smime.p7s Description: S/MIME Cryptographic Signature ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script strangeness...
On Fri, May 16, 2008 at 02:07:10PM +0930, Ian Blackwell alleged: Craig White wrote: On my CentOS 4.6 server, this works... if [ -z `grep entry_chooser.js /var/log/httpd/access_log` ] On my CentOS 5.1 server, this gives me the following error... ./test_file.scr: line 3: [: too many arguments Can anyone explain why the difference and suggest something that makes both cases happy? Thanks Craig ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos Not sure why 4.6 is allowing it, but your if test will be resolving to something like this:- if [ -z this line from your log file and another line and even more lines until your if test fails with too many arguments I hope you don't want me to keep typing to make the point ] To fix it, wrap the grep instead double quotes as well as the ticks - e.g. if [ -z `grep entry_chooser.js /var/log/httpd/access_log` ] Then the output from the grep will be seen as one long string, not a multitude of words from your log file. Even better is to use 'grep -q' to avoid possibly large string expansions... if grep -q entry_chooser.js /var/log/httpd/access_log ;then -- Garrick Staples, GNU/Linux HPCC SysAdmin University of Southern California Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html pgpF8kEh4F3yE.pgp Description: PGP signature ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script strangeness...
On Fri, 2008-05-16 at 14:07 +0930, Ian Blackwell wrote: Craig White wrote: On my CentOS 4.6 server, this works... if [ -z `grep entry_chooser.js /var/log/httpd/access_log` ] On my CentOS 5.1 server, this gives me the following error... ./test_file.scr: line 3: [: too many arguments Can anyone explain why the difference and suggest something that makes both cases happy? Not sure why 4.6 is allowing it, but your if test will be resolving to something like this:- if [ -z this line from your log file and another line and even more lines until your if test fails with too many arguments I hope you don't want me to keep typing to make the point ] To fix it, wrap the grep instead double quotes as well as the ticks - e.g. if [ -z `grep entry_chooser.js /var/log/httpd/access_log` ] Then the output from the grep will be seen as one long string, not a multitude of words from your log file. That works fine one CentOS 5 (double quotes and backtics) but not on CentOS 4.6 Thanks...I guess it's good enough for now. Craig ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script strangeness...
On Thu, 2008-05-15 at 22:00 -0700, Garrick Staples wrote: On Fri, May 16, 2008 at 02:07:10PM +0930, Ian Blackwell alleged: Craig White wrote: On my CentOS 4.6 server, this works... if [ -z `grep entry_chooser.js /var/log/httpd/access_log` ] On my CentOS 5.1 server, this gives me the following error... ./test_file.scr: line 3: [: too many arguments Can anyone explain why the difference and suggest something that makes both cases happy? Not sure why 4.6 is allowing it, but your if test will be resolving to something like this:- if [ -z this line from your log file and another line and even more lines until your if test fails with too many arguments I hope you don't want me to keep typing to make the point ] To fix it, wrap the grep instead double quotes as well as the ticks - e.g. if [ -z `grep entry_chooser.js /var/log/httpd/access_log` ] Then the output from the grep will be seen as one long string, not a multitude of words from your log file. Even better is to use 'grep -q' to avoid possibly large string expansions... if grep -q entry_chooser.js /var/log/httpd/access_log ;then for this purpose, -q didn't seem to matter much - thanks Craig ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script question
On Thu, Mar 13, 2008 at 12:04 PM, Jerry Geis [EMAIL PROTECTED] wrote: hi all, If I have a shell script on 5.1 that has 2 commands in the script... command1 command2 and command1 runs until it is kill'ed by some other process. Sometimes command2 runs and sometimes it doesnt (this is what it seems like). How can I be ensured that command2 will always run after command1 is killed? The script is not killed just command1. if command1;then true;fi command2 -- Marcelo ¿No será acaso que ésta vida moderna está teniendo más de moderna que de vida? (Mafalda) ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
[CentOS] shell script question
hi all, If I have a shell script on 5.1 that has 2 commands in the script... command1 command2 and command1 runs until it is kill'ed by some other process. Sometimes command2 runs and sometimes it doesnt (this is what it seems like). How can I be ensured that command2 will always run after command1 is killed? The script is not killed just command1. Thanks, jerry ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script question
On Thursday 13 March 2008 22:04:23 Jerry Geis wrote: If I have a shell script on 5.1 that has 2 commands in the script... command1 command2 and command1 runs until it is kill'ed by some other process. Sometimes command2 runs and sometimes it doesnt (this is what it seems like). How can I be ensured that command2 will always run after command1 is killed? The script is not killed just command1. Does command1 always need to be killed? How about: command1 command2 ? -- Fajar Priyanto | Reg'd Linux User #327841 | Linux tutorial http://linux2.arinet.org 22:29:55 up 10 min, 2.6.22-14-generic GNU/Linux Let's use OpenOffice. http://www.openoffice.org The real challenge of teaching is getting your students motivated to learn. signature.asc Description: This is a digitally signed message part. ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script question
On Thu, Mar 13, 2008 at 11:04:23AM -0400, Jerry Geis alleged: hi all, If I have a shell script on 5.1 that has 2 commands in the script... command1 command2 and command1 runs until it is kill'ed by some other process. Sometimes command2 runs and sometimes it doesnt (this is what it seems like). How can I be ensured that command2 will always run after command1 is killed? The script is not killed just command1. In this example, command2 will always run after command1. The script must be getting killed. -- Garrick Staples, GNU/Linux HPCC SysAdmin University of Southern California Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html pgpNuAsIadECT.pgp Description: PGP signature ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] shell script question
On Thu, Mar 13, 2008 at 10:29:58PM +0700, Fajar Priyanto alleged: On Thursday 13 March 2008 22:04:23 Jerry Geis wrote: If I have a shell script on 5.1 that has 2 commands in the script... command1 command2 and command1 runs until it is kill'ed by some other process. Sometimes command2 runs and sometimes it doesnt (this is what it seems like). How can I be ensured that command2 will always run after command1 is killed? The script is not killed just command1. Does command1 always need to be killed? How about: command1 command2 ? This would ensure that command2 is never run after command1 is killed (assuming command1 is not trapping the signal and exiting successfully). -- Garrick Staples, GNU/Linux HPCC SysAdmin University of Southern California Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html pgpAovBB3ywOc.pgp Description: PGP signature ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos