Re: help with shell script

2005-10-13 Thread Peter Matulis

--- Peter Matulis [EMAIL PROTECTED] wrote:

 
 --- Philip Hallstrom [EMAIL PROTECTED] wrote:
 
   1. This gives me the amount of space (kB) taken up by the 10 largest 
   ports:
  
   $ pkg_info -as | grep ^[0-9] | sort -gr | head -10 | cut -c 1-6
  
   2. Using one figure from above list I produce the details of the 
   corresponding port:
  
   $ pkg_info -as | grep -B3 240695
  
   Output:
   --
   Information for linux_base-8-8.0_6:
  
   Package Size:
   240695  (1K-blocks)
   --
  
   I would like the output of the script to be the above but for all ten 
   ports (~40 lines;
  insert
   a blank line between each?).  I know I need some sort of iteration but I 
   am rusty on
  scripting.
   Can anyone help?
  
  This should get you close... if you want only the top 10 just add more 
  pipes to the end with sort and head...
  
  
  #!/bin/sh
  
  newline='\
  '
  
  pkg_info -as | \
   tr '\n' ' ' | \
   sed -e 's/Package Size://g' \
   -e s/(1K-blocks)/$newline/g |\
   sed -e 's/^  *Information for //'
  
 
 What I need is the size as the first item (not the second) on each line.  
 Then I can use
 sort.

Allrighty, I employed some awk to get a good enough output:


#!/bin/sh

newline='\
'

pkg_info -as | \
 tr '\n' ' ' | \
 sed -e 's/Package Size://g' \
 -e s/(1K-blocks)/$newline/g | \
 tr ':' ' ' | \
 awk '{print$4,   ,$3}' | \
 sort -gr | \
 head -30


Thanks.






__ 
Find your next car at http://autos.yahoo.ca
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: help with shell script

2005-10-13 Thread Parv
in message [EMAIL PROTECTED],
wrote Philip Hallstrom thusly...

 #!/bin/sh
 
 newline='\
 '
 
 pkg_info -as | \
 tr '\n' ' ' | \
 sed -e 's/Package Size://g' \
 -e s/(1K-blocks)/$newline/g |\
 sed -e 's/^  *Information for //'

Holy cow, i was going about it all wrong!  No wonder it was taking
me too long for this; i was parsing some things instead of removing
others.


  - Parv

-- 

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: help with shell script

2005-10-13 Thread Parv
in message [EMAIL PROTECTED],
wrote Peter Matulis thusly...

Could your please wrap lines around 69 or so characters?

 What I need is the size as the first item (not the second) on each
 line.  Then I can use sort.

You can easily specify the column|key to sort on via -k flag ...

  { echo polka 1 ; echo dot 4; } \
  | sort -k2,2nr



  - Parv

-- 

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


help with shell script

2005-10-12 Thread Peter Matulis
Hi.  I am writing up a doc for the fbsd community that covers usage of ports.  
I have two
commands that allow me to assertain the amount of disk space being utilized by 
currently
installed ports.  I would like to make a shell script (bourne or bash) out of 
them but I am not
sure how.

1. This gives me the amount of space (kB) taken up by the 10 largest ports:

$ pkg_info -as | grep ^[0-9] | sort -gr | head -10 | cut -c 1-6

Example output:
--
240695
59274   
55526   
54271   
47418   
42644   
35364   
31091   
29181   
28745
--

2. Using one figure from above list I produce the details of the corresponding 
port:

$ pkg_info -as | grep -B3 240695

Output:
--
Information for linux_base-8-8.0_6:

Package Size:
240695  (1K-blocks)
--

I would like the output of the script to be the above but for all ten ports 
(~40 lines; insert
a blank line between each?).  I know I need some sort of iteration but I am 
rusty on scripting.
 Can anyone help?






__ 
Find your next car at http://autos.yahoo.ca
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: help with shell script

2005-10-12 Thread Philip Hallstrom
Hi.  I am writing up a doc for the fbsd community that covers usage of 
ports.  I have two commands that allow me to assertain the amount of 
disk space being utilized by currently installed ports.  I would like to 
make a shell script (bourne or bash) out of them but I am not sure how.


1. This gives me the amount of space (kB) taken up by the 10 largest ports:

$ pkg_info -as | grep ^[0-9] | sort -gr | head -10 | cut -c 1-6

2. Using one figure from above list I produce the details of the corresponding 
port:

$ pkg_info -as | grep -B3 240695

Output:
--
Information for linux_base-8-8.0_6:

Package Size:
240695  (1K-blocks)
--

I would like the output of the script to be the above but for all ten ports 
(~40 lines; insert
a blank line between each?).  I know I need some sort of iteration but I am 
rusty on scripting.
Can anyone help?


This should get you close... if you want only the top 10 just add more 
pipes to the end with sort and head...



#!/bin/sh

newline='\
'

pkg_info -as | \
tr '\n' ' ' | \
sed -e 's/Package Size://g' \
-e s/(1K-blocks)/$newline/g |\
sed -e 's/^  *Information for //'


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: help with shell script

2005-10-12 Thread Peter Matulis

--- Philip Hallstrom [EMAIL PROTECTED] wrote:

  1. This gives me the amount of space (kB) taken up by the 10 largest ports:
 
  $ pkg_info -as | grep ^[0-9] | sort -gr | head -10 | cut -c 1-6
 
  2. Using one figure from above list I produce the details of the 
  corresponding port:
 
  $ pkg_info -as | grep -B3 240695
 
  Output:
  --
  Information for linux_base-8-8.0_6:
 
  Package Size:
  240695  (1K-blocks)
  --
 
  I would like the output of the script to be the above but for all ten ports 
  (~40 lines;
 insert
  a blank line between each?).  I know I need some sort of iteration but I am 
  rusty on
 scripting.
  Can anyone help?
 
 This should get you close... if you want only the top 10 just add more 
 pipes to the end with sort and head...
 
 
 #!/bin/sh
 
 newline='\
 '
 
 pkg_info -as | \
  tr '\n' ' ' | \
  sed -e 's/Package Size://g' \
  -e s/(1K-blocks)/$newline/g |\
  sed -e 's/^  *Information for //'
 

What I need is the size as the first item (not the second) on each line.  Then 
I can use sort.







__ 
Find your next car at http://autos.yahoo.ca
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Help running shell script from cron

2005-09-09 Thread Sandy Knight
I am having trouble configuring my shell scripts to run under cron (user level, not root). I have 
set up a test.sh script which sends me an email, it works fine from the command line (ssh). the 
script is as follows:


#!/bin/sh
echo helloworld | mail -s helloworld [EMAIL PROTECTED]
php /home/a_user/cron/test.php


As you can see I am also trying to get a php script to run (this is my ultimate 
aim).

My crontab is as follows:

# /home/a_user
#
SHELL=/bin/sh
PATH=/home/a_user/cron
HOME=/home/a_user
#
#
#minute hourmdaymonth   wdaycommand
#
#
*/5 * * * *   /home/a_user/cron/test.sh


I have done the following:

$ pwd

/home/a_user

$ crontab cron/myCronTab

$ crontab -l

{output - see above}


Crontab is trying to run my script as I receive an email every 5 minutes saying:

/home/a_user/cron/test.sh: not found


The permissions for the scripts are:

$ ls -lt cron/

-rw-r--r--  1 a_user  vusers   322 Sep  9 12:27 myCronTab
-rwxr-xr-x  1 a_user  vusers   107 Sep  9 12:16 test.sh
-rwxr-xr-x  1 a_user  vusers99 Sep  4 17:58 test.php

Thank you in advance,

Sandy
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Help running shell script from cron

2005-09-09 Thread jdyke
there is a possibility that the 'not found' is coming from your call to php and 
not that it can't find test.sh


either comment out that php line, or use
/full/path/to/php /home/a_user/cron/test.php

HTH
Jeff

Sandy Knight wrote:
I am having trouble configuring my shell scripts to run under cron (user 
level, not root). I have set up a test.sh script which sends me an 
email, it works fine from the command line (ssh). the script is as follows:


#!/bin/sh
echo helloworld | mail -s helloworld [EMAIL PROTECTED]
php /home/a_user/cron/test.php


As you can see I am also trying to get a php script to run (this is my 
ultimate aim).


My crontab is as follows:

# /home/a_user
#
SHELL=/bin/sh
PATH=/home/a_user/cron
HOME=/home/a_user
#
#
#minute hourmdaymonth   wdaycommand
#
#
*/5 * * * *   /home/a_user/cron/test.sh


I have done the following:

$ pwd

/home/a_user

$ crontab cron/myCronTab

$ crontab -l

{output - see above}


Crontab is trying to run my script as I receive an email every 5 minutes 
saying:


/home/a_user/cron/test.sh: not found


The permissions for the scripts are:

$ ls -lt cron/

-rw-r--r--  1 a_user  vusers   322 Sep  9 12:27 myCronTab
-rwxr-xr-x  1 a_user  vusers   107 Sep  9 12:16 test.sh
-rwxr-xr-x  1 a_user  vusers99 Sep  4 17:58 test.php

Thank you in advance,

Sandy
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to 
[EMAIL PROTECTED]



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Help running shell script from cron

2005-09-09 Thread Frank Mueller - emendis GmbH

Always use full path in Scrips, e.g.

/bin/echo ...
/usr/local/bin/php ..

Greetz,

Ice


Sandy Knight schrieb:
I am having trouble configuring my shell scripts to run under cron (user 
level, not root). I have set up a test.sh script which sends me an 
email, it works fine from the command line (ssh). the script is as follows:


#!/bin/sh
echo helloworld | mail -s helloworld [EMAIL PROTECTED]
php /home/a_user/cron/test.php


As you can see I am also trying to get a php script to run (this is my 
ultimate aim).


My crontab is as follows:

# /home/a_user
#
SHELL=/bin/sh
PATH=/home/a_user/cron
HOME=/home/a_user
#
#
#minute hourmdaymonth   wdaycommand
#
#
*/5 * * * *   /home/a_user/cron/test.sh


I have done the following:

$ pwd

/home/a_user

$ crontab cron/myCronTab

$ crontab -l

{output - see above}


Crontab is trying to run my script as I receive an email every 5 minutes 
saying:


/home/a_user/cron/test.sh: not found


The permissions for the scripts are:

$ ls -lt cron/

-rw-r--r--  1 a_user  vusers   322 Sep  9 12:27 myCronTab
-rwxr-xr-x  1 a_user  vusers   107 Sep  9 12:16 test.sh
-rwxr-xr-x  1 a_user  vusers99 Sep  4 17:58 test.php

Thank you in advance,

Sandy
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to 
[EMAIL PROTECTED]


--
Frank Mueller
eMail: [EMAIL PROTECTED]
Mobil: +49.177.6858655
Fax: +49.951.3039342

emendis GmbH
Hofmannstr. 89, 91052 Erlangen, Germany
Fon: +49.9131.817361
Fax: +49.9131.817386

Geschaeftsfuehrer: Gunter Kroeber, Volker Wiesinger
Sitz Erlangen, Amtsgericht Fuerth HRB 10116
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Help running shell script from cron

2005-09-09 Thread Kevin Kinsey

Sandy Knight wrote:


I am having trouble configuring my shell scripts to run under
cron (user level, not root). I have set up a test.sh script which
sends me an email, it works fine from the command line (ssh). the 
script is as follows:


#!/bin/sh
echo helloworld | mail -s helloworld [EMAIL PROTECTED]
php /home/a_user/cron/test.php


As you can see I am also trying to get a php script to run (this is my 
ultimate aim).


My crontab is as follows:

# /home/a_user
#
SHELL=/bin/sh
PATH=/home/a_user/cron
HOME=/home/a_user
#
#
#minute hourmdaymonth   wdaycommand
#
#
*/5 * * * *   /home/a_user/cron/test.sh


I have done the following:

$ pwd

/home/a_user

$ crontab cron/myCronTab

$ crontab -l

{output - see above}


Crontab is trying to run my script as I receive an email every 5 
minutes saying:


/home/a_user/cron/test.sh: not found


The permissions for the scripts are:

$ ls -lt cron/

-rw-r--r--  1 a_user  vusers   322 Sep  9 12:27 myCronTab
-rwxr-xr-x  1 a_user  vusers   107 Sep  9 12:16 test.sh
-rwxr-xr-x  1 a_user  vusers99 Sep  4 17:58 test.php

Thank you in advance,

Sandy




For starters, assume cron to be totally ignorant about
paths.  That means it doesn't know whereis anything,
etc.  Hard-code things, IOW.

That said, and I may be a bit confused, but why try
to supersede whatever limited environment cron
may already have by setting more env vars?

Specifically in this case, try using a crontab with
no env vars set (specifically) and hard code all the paths.
Simply run crontab -e and put /usr/local/bin/php -q /path/to/my/script.php
there and see what happens.

HTH,

Kevin Kinsey
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


need help on shell script

2004-06-17 Thread klr
Hi list,

I read http://www.linuxgazette.com/node/view/9074 and tried to adopt this
script to my ipfw firewall:

#!/bin/sh
tail -f /var/log/security | \
  awk '
$0 ~ /ICMP/ {
system(cat /root/sounds/icmp.wav  /dev/dsp );
}
$0 ~ /TCP/ {
system(cat /root/sounds/tcp.wav  /dev/dsp );
}
$0 ~ /UDP/ {
system(cat /root/sounds/udp.wav  /dev/dsp );
}
   '

This is what I got. However, sounds won't play one after another. e.g, if
3 packets are blocked at the same time, 2 TCP and one UDP, the system will
always wait for a sound to finish before playing the next. I want it to be
able to play the sounds in sequence (as fast as possible), but I couldn't
figure a way out!

Any shell script guru could give an helping hand? ;)

Regards

-- 
www.6s-gaming.com

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: need help on shell script

2004-06-17 Thread Adam Smith
On Thu, Jun 17, 2004 at 08:15:23PM -, [EMAIL PROTECTED] said:
 Hi list,
 
 I read http://www.linuxgazette.com/node/view/9074 and tried to adopt this
 script to my ipfw firewall:
 
 #!/bin/sh
 tail -f /var/log/security | \
   awk '
 $0 ~ /ICMP/ {
 system(cat /root/sounds/icmp.wav  /dev/dsp );
 }
 $0 ~ /TCP/ {
 system(cat /root/sounds/tcp.wav  /dev/dsp );
 }
 $0 ~ /UDP/ {
 system(cat /root/sounds/udp.wav  /dev/dsp );
 }
'
 
 This is what I got. However, sounds won't play one after another. e.g, if
 3 packets are blocked at the same time, 2 TCP and one UDP, the system will
 always wait for a sound to finish before playing the next. I want it to be
 able to play the sounds in sequence (as fast as possible), but I couldn't
 figure a way out!

This is the behaviour of the device, not your script.  Only one process can
access the device at any one time, and so your subsequent sounds must wait
for the first one to finish before it will be able to use /dev/dsp.

When using /dev/dsp, programs like artsd (which comes with KDE) allow other
artsd-aware programs to send sound events through the artsd daemon, and
artsd controls all the mixing of sounds together to send them out through
/dev/dsp.

So, you need something like this to play your events, rather than catting
them to /dev/dsp.  Unfortunately I don't know of any console programs that
do this.  Try looking in /usr/ports/audio :)


-- 
Adam Smith
Internode   : http://www.internode.on.net
Phone   : (08) 8228 2999

Dog for sale:  Eats lots and is fond of children.
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]